Binary Search Algorithm

What is Binary Search?

Binary search is an efficient algorithm for finding an item from a sorted list of elements.

Steps of Binary Search

  1. Find the middle element of the list.
  2. If it's the target, return it.
  3. If the target is less, search the left half. Otherwise, search the right half.

Visual Representation

Binary Search Diagram

Want to learn more? Visit Wikipedia - Binary Search.