Why does bisection search freeze forever on the square root of 0.25, and how does one change to the endpoints fix it?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
A bisection search is about to begin over the interval [0, 60]. The next guess is always the midpoint of the current interval.
Compute that midpoint and assign it to first_guess.
The stuck interval for 0 < x < 1
State that the square root of a value under 1 lies above that value, and trace x = 0.5 with low = 0 and high = x to the point where the guess stops changing.
Print debugging and the exact float 0.5
Record the print of low, high and guess placed inside the loop, the repeating 0.5 output it produces, and the note that 0.5 is a power of 2 stored exactly.
Endpoint if/else for any positive x
Write the guard that sets low = 0, high = x when x >= 1 and low = x, high = 1 when 0 < x < 1, and note the cost of one spare guess from a loose endpoint.