How do just low, high, and a midpoint guess collapse 23 million square-root guesses down to about 30?
Short drills on what this video just taught. Write the code, run the checks, and reveal the answer only if you are stuck.
Bisection search for the square root of 90 starts on the interval that runs from low = 0 to high = 90. Its first guess is the midpoint of that interval.
Compute that first guess and assign it to first_guess.
Endpoints, midpoint, and the boundary update
Write the setup low = 0, high = x, guess = (high + low)/2, the if/else that moves low up to the guess when guess**2 < x and high down otherwise, and the recomputed midpoint.
The loop test carried over unchanged
Record that abs(guess**2 - x) >= epsilon is the same condition used by the approximation method, and mark the guess-generation line as the only part that differs.
Hand-trace for the square root of 36
Step through x = 36, epsilon = 1, low = 0, high = 36 with guesses 18, 9, 4.5, 6.75 down to about 6.0469, noting each endpoint move.
The guess count k = log n
Derive n / 2**k = 1, then n = 2**k and k = log n, and record the measured 23 million guesses against 30 guesses for x = 54321.