Showing AQAChange board

Deep Dive: The Steps of Binary Search

Test yourself on Binary Search with exam style questions, marked instantly.

Flashcards that come back just before you would forget them.

A revision plan that remembers what you know and shows what to do next.

See which topics you have nailed and which need another look.

Quiz yourself on Binary SearchGet your flashcardsBuild my revision planTrack my progress

Deep Dive: The Steps of Binary Search

  1. Make sure the list is sorted.
  2. Set the low pointer to the first position and the high pointer to the last position.
  3. Find the midpoint: (low + high) DIV 2. DIV means divide and drop any remainder.
  4. Compare the middle item with the target.
    • Equal: the target is found. Stop.
    • Target is larger: it must be in the right half, so set low to mid + 1.
    • Target is smaller: it must be in the left half, so set high to mid - 1.
  5. Repeat from step 3. If low becomes greater than high, the target is not in the list.

Make this stick

Signing in gives access to all PrepWise features.

PrepWise is a trading name of A3M Quality Solutions Limited, registered in England and Wales, company number 14959172. Registered office: 202 Stroud Road, Gloucester, GL1 5LA. ICO registration ZC267069.