Count Binary Search Steps
Count Binary Search Steps
Write binary_search_steps(values: list[int], target: int) -> int that runs a binary search on the sorted list but returns how many times a middle element was examined, whether or not the target was found: keep low, high and a steps counter, and while low is at most high compute mid with (low + high) // 2, add one to steps, and either return steps on a hit, move low to mid + 1 when the middle is too small, or move high to mid - 1. Return steps after the loop too. Sixteen values never take more than five steps, which is the O(log n) promise made visible. Do NOT write a main block or any top-level test code; the tests construct the calls. Input: two lines, a space-separated sorted list of integers (possibly empty) and then the target; the tests print the count your function returns.
Expected Output:
5= newline. The output ends with a newline — print one after the last line.
Your Output
Run your code to see the output here...