Remembering Binary Search

Binary search is a common algorithm taught in schools and while the idea is simple to understand, the real challenge is often implementing the algorithm. For those already familiar with the algorithm, feel free to scroll down to the implementation.

This article will aim to teach you how to remember binary search such that you will never have problems implementing it again.

Lets outline a few key ideas about binary search:

  • Binary search can only be applied to sorted arrays/data structures AND sorted values