logo CodeStepByStep logo

binary_search_values3

Language/Type: Python parameters references

Consider the following sorted list of integers. When a binary search is performed on this list for each of the following integer values, what indexes are examined in order? What result value is returned? (Assume that when the value is not found, the function returns -(insertion point + 1).)

# index     0   1   2   3   4   5   6   7   8   9  10  11
numbers = [-1,  3,  5,  8, 15, 18, 22, 39, 40, 42, 50, 57]
13, indexes examined
13, value returned
39, indexes examined
39, value returned
50, indexes examined
50, value returned
2, indexes examined
2, 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.