# TAOCP 6.2.1 Searching an Ordered Table

> Study guide to TAOCP 6.2.1 Searching an Ordered Table. Binary search and its variants: uniform binary search, Fibonacci search, and interpolation search…

Updated October 20, 2026.

## Summary {#summary}

TAOCP 6.2.1 Searching an Ordered Table: Binary search and its variants: uniform binary search, Fibonacci search, and interpolation search, with analysis and a careful look at how easy it is to get binary search wrong. Budget about 7 hours; do exercises 3, 1 and 2.

## Key facts {#key-facts}

- Week 109 of 145 on the cracked.guide path, in [TAOCP Vol 3: Sorting and Searching](https://cracked.guide/taocp/volume-3).
- Time budget: about 7 hours.
- 30 exercises in the section, rated 15 to M42; the guide picks 8.
- Picked exercises with Knuth's triangle for recommended: 1, 2, 24, 29, 7, 23 and 25.
- Before you start: 6.1 Sequential Searching.

## Week 109 goals {#objectives}

By the end of week 109 you can:

- Trace binary search and its probe sequence on a small sorted table.
- Explain when interpolation search beats binary search and when it fails.
- Implement binary search and test it exhaustively on small arrays.

## This week's steps {#steps}

- Read §6.2.1 Searching an Ordered Table: Write binary search from memory, then test it exhaustively on all arrays up to size 10 and all targets.
- Work the exercises (8 picked): Start with Ex 3, Ex 1, Ex 2; log what you solve below.
- Write down one thing you'd explain to someone: A few sentences in your own words in Your notes: the idea, why it works, an example. 30 words ticks this.

## Exercises {#exercises}

This section has 30 exercises, rated 15 to M42, and Knuth marks 7 of them with the triangle for recommended. Binary search is easy to get wrong, so 1, 2 and 7 are worth doing carefully even if they look simple. Implement Algorithm B, uniform binary search and the Bottenbruch variant from 23, and test each against a linear scan. 19 and 22 are research-level.

Worth your time:

- 3 (rated 15): Identify the search method behind a given tree and compute its average costs.
- 1 (rated 21, recommended): Prove what the bounds mean when binary search fails. This is the loop invariant.
- 2 (rated 22, recommended): Do two tempting shortcuts in the bound updates still work?
- 24 (rated 23, recommended): Binary search on the heap-ordered layout, using doubling instead of halving. Cache-friendly search.
- 29 (rated 22, recommended): Search keys that are only sorted up to a fixed involution.
- 7 (rated M22, recommended): Do small changes to the start of uniform binary search break it?
- 23 (rated 25, recommended): Bottenbruch's variant that tests for equality only at the end. The form most libraries use.
- 25 (rated M25, recommended): Relate internal and external node counts per level by generating functions. The math stretch.

## Why it matters {#why}

Binary search is famously hard to write correctly. Knowing the variants also helps with things like branch-free search and searching on sorted disk pages.

## Before you start {#before}

- 6.1 Sequential Searching

## How to approach it {#approach}

Write binary search from memory, then test it exhaustively on all arrays up to size 10 and all targets. Implement interpolation search and test it on uniform and skewed data.

## Common traps {#traps}

- Off-by-one in bounds and infinite loops when lo and hi are adjacent.
- Midpoint overflow on very large arrays.

## Links {#links}

- [Knuth's TAOCP page (editions, errata, MIX/MMIX)](https://www-cs-faculty.stanford.edu/~knuth/taocp.html)
- [Vol 3 errata (plain text, from Knuth)](https://www-cs-faculty.stanford.edu/~knuth/err3.textxt)
- [Wikipedia: Binary search algorithm](https://en.wikipedia.org/wiki/Binary_search_algorithm)
- [Wikipedia: Interpolation search](https://en.wikipedia.org/wiki/Interpolation_search)
- [Wikipedia: Fibonacci search technique](https://en.wikipedia.org/wiki/Fibonacci_search_technique)
- [Hacker News: Nearly all binary searches and mergesorts are broken](https://news.ycombinator.com/item?id=42664400)

---

Source: https://cracked.guide/guide/knuth-w092-0
cracked.guide: A free, dated 145-week path to getting genuinely cracked at programming.
