Template I

Key Attributes:

  • The Most basic and elementary form of Binary Search.

  • Search Condition can be determined without comparing to the element's neighbors (or use specific elements around it)

  • No post-processing required because at each step, you are checking to see if the element has been found. If you reach the end, then you know the element is not found

Distinguishing Syntax:

  • Initial Condition: left = 0, right = length-1

  • Termination: left <= right

  • Searching Left: right = mid-1

  • Searching Right: left = mid+1

Last updated