Binary Search Formula

The Formula

O(\log n) time complexity

When to use: Looking up a word in a dictionary: open to the middle, then go left or right depending on where your word falls.

Quick Example

Find 37 in [1,5,12,23,37,49,56]: check middle (23), go right, check middle (49), go left, find 37.

What This Formula Means

An efficient algorithm for finding a target value in a sorted list by repeatedly halving the search range.

Looking up a word in a dictionary: open to the middle, then go left or right depending on where your word falls.

Why This Formula Matters

Binary search is orders of magnitude faster than linear search for large sorted datasets.

Frequently Asked Questions

What is the Binary Search formula?

An efficient algorithm for finding a target value in a sorted list by repeatedly halving the search range.

How do you use the Binary Search formula?

Looking up a word in a dictionary: open to the middle, then go left or right depending on where your word falls.

Why is the Binary Search formula important in CS Thinking?

Binary search is orders of magnitude faster than linear search for large sorted datasets.

What do students get wrong about Binary Search?

Binary search only works on sorted data โ€” applying it to unsorted data gives wrong results.

What should I learn before the Binary Search formula?

Before studying the Binary Search formula, you should understand: searching, array, efficiency.