Binary Search Algorithm

Binary search is an efficient algorithm for finding an item from a sorted list of items. It works by repeatedly dividing in half the portion of the list that could contain the item, until you've narrowed down the possible locations to just one.

Step: 0
Enter a target value and click "Start Search" to begin.

Binary Search Algorithm Steps:

  1. Start with a sorted array and define the search range (left and right pointers)
  2. Find the middle element of the current search range
  3. Compare the middle element with the target value
  4. If they match, the search is complete
  5. If the target is less than the middle element, search the left half
  6. If the target is greater than the middle element, search the right half
  7. Repeat until the target is found or the search range is empty