# TAOCP 6.5 Retrieval on Secondary Keys

> Study guide to TAOCP 6.5 Retrieval on Secondary Keys. Searching on attributes other than the primary key: inverted files, multi-attribute queries, range and…

Updated October 20, 2026.

## Summary {#summary}

TAOCP 6.5 Retrieval on Secondary Keys: Searching on attributes other than the primary key: inverted files, multi-attribute queries, range and partial-match queries, and superimposed coding (the idea behind Bloom filters). Budget about 7 hours; do exercises 3, 9 and 6.

## Key facts {#key-facts}

- Week 116 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.
- 20 exercises in the section, rated 19 to M47; the guide picks 7.
- Picked exercises with Knuth's triangle for recommended: 6, 16, 1 and 17.
- Before you start: 6.4 Hashing.

## Week 116 goals {#objectives}

By the end of week 116 you can:

- Use inverted lists to answer AND queries on secondary keys.
- Explain how superimposed coding allows false drops but never false negatives.
- Compute a Bloom filter's best number of hash functions from bits per key.

## This week's steps {#steps}

- Read §6.5 Retrieval on Secondary Keys: Build a tiny inverted index for a folder of text files and answer AND queries.
- Work the exercises (7 picked): Start with Ex 3, Ex 9, Ex 6; 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 20 exercises, rated 19 to M47, and Knuth marks 5 of them with the triangle for recommended. The set leans on combinatorial designs (Steiner triple systems, block designs). Do 3 to check you understand false drops in superimposed coding, then 14 if you have built k-d trees or quadtrees. 5 and 20 are open-ended.

Worth your time:

- 3 (rated 19): Which queries produce particular false drops in the recipe example.
- 9 (rated M20): Verify a construction of Steiner triple systems.
- 6 (rated M20, recommended): Average locations per query for composed combinatorial hash functions.
- 16 (rated 25, recommended): Build superimposed codes from a triple system so no codeword is covered by two others.
- 14 (rated 28): Deletion in quadtrees and k-d trees. A real design problem.
- 1 (rated M27, recommended): Construct permutations that put every small subset first somewhere.
- 17 (rated M30, recommended): Analyze a bit-interleaving scheme for partial-match buckets. The stretch.

## Why it matters {#why}

Inverted indexes power every search engine, and Bloom filters are everywhere from databases to network caches.

## Before you start {#before}

- 6.4 Hashing

## How to approach it {#approach}

Build a tiny inverted index for a folder of text files and answer AND queries. Implement a Bloom filter and measure its false positive rate.

## Common traps {#traps}

- Picking the number of Bloom filter hash functions without doing the math.

## 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: Inverted index](https://en.wikipedia.org/wiki/Inverted_index)
- [Wikipedia: Bloom filter](https://en.wikipedia.org/wiki/Bloom_filter)
- [Hacker News: How bloom filters made SQLite 10x faster](https://news.ycombinator.com/item?id=42486610)

---

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