---
answer: direct
beat: system-design
source: 1 article · updated: August 2, 2026
---

Why pair a trie with a top-k heap instead of just returning all candidates?

A trie node holds millions of descendants in real dictionaries. A top-k heap (min-heap of size k) tracks the k best words by frequency/popularity. Autocomplete returns the heap top-k instantly without scanning all descendants. Cost: O(k log k) extraction, where k is typically 5–10.

Answered in

Tries: Why Autocomplete Doesn't Scan Every Word

A trie finds all words with a prefix in O(p) time, independent of dictionary size. Radix compression and top-k heaps make autocomplete instant.

Crashtech Editorial August 2, 2026 System Design & Architecture

Read the full analysis

Other questions this article answers

More system design & architecture questions

Every answer on Crashtech is written by the editor of the article it comes from — never auto-summarised. Browse all answers or the System Design & Architecture beat.