Bisection algorithm