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
1
Expert's answer
2010-10-16T12:23:36-0400
Please, clarify your question or submit it to our site as an assignment, just follow this link and our experts will help you.
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments