Q15.webp
M

Q15.webp

  • Media owner Miwa88
  • Ngày thêm
Kizspy | Question: 15
(Choose 1 answer)
(See picture)
A. 3
B. 2
C. 4
D. 5
E. None of the other choices is correct
Use the binary search algorithm to find the location of 10 in
the sequence {1, 4, 5, 7, 8, 10, 12}. How many iterations are
needed?
ALGORITHM The Binary Search Algorithm.
procedure binary search (x: integer, a1, a2,..., an increasing integers)
i=1{i is left endpoint of search interval}
jis right endpoint of search interval}
jn
while i < j
begin
end
m = [(i + j)/2]
if xam then im +1
else j := m
if xa; then location:= i
else location:= 0
{location is the subscript of the term equal to x, or 0 if x is not found}

Thông tin

Category
MAD101
Thêm bởi
Miwa88
Ngày thêm
Lượt xem
2,553
Lượt bình luận
8
Rating
0.00 star(s) 0 đánh giá

Share this media

Back
Bên trên Bottom