Skip to main content

Binary Search O(log n)

Binary Search

What is Binary Search?

Binary search is the most efficient searching algorithm having a run-time complexity of O(log2 N)

Works only on sorted list of elements

How does it search?

  • Compares the middle element of the list with the target element
    • If target element matches the middle element
      • It's position in the list is returned
    • Else, the list is divided in two halves
      • The half that includes the target element is split in half ect..
    • Until there is a match or 0 items left

Links