logo CodeStepByStep logo

binary_search_numbers

Language/Type: Python searching binary search
Related Links:

Given the following sorted lists of integers: What indexes will be examined as the middle element by a binary search for the target value 8 when the search is run on the following input lists? What value will the binary search algorithm return?

(Notice that the input list e. isn't in sorted order. What can you say about the binary search algorithm's result?)

#  index       0   1   2   3   4   5   6   7   8
a. numbers = [ 1,  3,  6,  7,  8, 10, 15, 20, 30]
b. numbers = [ 1,  2,  3,  4,  5,  7,  8,  9, 10]
c. numbers = [ 1,  2,  3,  4,  5,  6,  7,  8,  9]
d. numbers = [ 8,  9, 12, 14, 15, 17, 19, 25, 31]
e. numbers = [ 6,  5,  8, 19,  7, 35, 22, 11,  9]
a. indexes examined
a. value returned
b. indexes examined
b. value returned
c. indexes examined
c. value returned
d. indexes examined
d. value returned
e. indexes examined
e. value returned

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.