Learn

Binary Search: Python

Iterative Binary Search

Anything recursive can be written iteratively.

As a final exercise, we’ll implement the binary search algorithm using iteration.

Our strategy remains largely the same as the recursive approach which used pointers.

Instead of recursive calls, we’ll substitute a `while`

loop.

Complete the `binary_search()`

skeleton.

You’ll need to:

- Fill in the condition for the
`while`

loop - Calculate the middle index using pointers
- Set the
`left_pointer`

when appropriate - Set the
`right_pointer`

when appropriate