63 220
Assignments Done
99,3%
Successfully Done
In July 2018

Answer to Question #774 in Other Programming & Computer Science for Krrish

Question #774
1 b ← 0
2 e ← |a|-1
3 repeat
4 m ← floor((b+e)/2)
5 if (a[m] < k) then
6 b ← m + 1
7 else if (k < a[m]) then
8 e ← m - 1
9 end if
10 until (a[m]=k) or (e<b)
11 f ← a[m]=k

and the answer page looks like this
1: comments line# b e m k f a
a[0] a[1]a[2][3]
pre ? ? ? 3 ? 0 2 4 8
2: comments line# b e m k f a
a[0] a[1] a[2] a[3]
pre ? ? ? 9 ? 0 2 4 8
3: comments line# b e m k f a
a[0] a[1] a[2] a[3]
pre ? ? ? 9 ? 0 2 4 8

Expert's answer
Please, clarify your question or submit it to our site as an assignment, just follow this link and our experts will help you.

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions