Indexing Mind Map

Algorithm & Systems Visualizations

Every indexing visualization on this site on one map. The branches are the main ideas. Each leaf is a page; the grey line under it is the one thing to remember about it. Click a branch to focus on it, click a page to open it.

Recall mode hides the page names. Read the hint, say the name, then click the "?" to check.

1. How the map is organized

Overview of the indexing mind map: Ordered search, Hash tables, Caches, Tries, Disk trees, Spatial indexes, Range queries, Sketches and sampling.
The map at a glance: 8 branches, 40 pages.

Ask what kind of question the index must answer:

  • Exact key, or a range in order? Exact only: hash tables (and caches built on them). In order: ordered search in memory, disk trees on disk.
  • Is the key a string you search by prefix? Then a trie. Is it a point on a map? A spatial index.
  • Is the question a sum over a range of positions? That is range queries.
  • Is an approximate answer in tiny memory enough? That is sketches and sampling.

2. The branches side by side

BranchLookup timeKeeps order?Answer
Ordered searchO(log n)yesexact
Hash tablesO(1) averagenoexact
CachesO(1)by recent usehit or miss
TriesO(key length)yesexact, prefixes
Disk treesO(logB n) page readsyesexact, ranges
Spatial indexesabout O(log n) per queryby areaexact, near points
Range queriesO(log n)by positionexact sums
Sketches and samplingO(1) or O(k)noapproximate

3. Five facts to remember

  • A plain BST can become a list (O(n)); balanced trees keep the height O(log n).
  • Hash tables give O(1) average lookups but cannot answer range or sorted-order queries.
  • A B+ tree keeps all data in linked leaves, so range scans just walk the leaves.
  • A Bloom filter can say "maybe present" wrongly, but never "absent" wrongly.
  • A Fenwick tree and a segment tree both do point update and range sum in O(log n).

See all indexing pages in the index, or the other mind maps.