AH – Binary Search

binsear

Binary search is a more efficient way of searching a sorted list.

The Python function given gives you an example of how this might be implemented. It either returns the found position or -1 meaning that the value has not been found.

There are other implementations available that make use of different constructs including recursion.

 

Leave a Reply

Your email address will not be published. Required fields are marked *