logo CodeStepByStep logo

binary_search_values

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 -1.)

# index      0   1   2   3   4   5   6   7   8   9  10  11  12  13
numbers = [-30, -9, -6, -4, -2, -1,  0,  2,  4, 10, 12, 17, 22, 30]
-5, indexes examined
-5, value returned
0, indexes examined
0, value returned
11, indexes examined
11, value returned
-100, indexes examined
-100, 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.