A trie (or prefix tree) stores strings character by character, sharing prefixes so that "apple" and "apricot" split only after the "apr" they both carry. Every node holds an array of child pointers, one slot per possible byte value — up to 256 slots for a full byte alphabet.
That sounds fine until you notice the waste. A node holding a single child still allocates 255 empty slots. Real datasets are sparse: IP routing tables, dictionary lookups and database indexes almost always have far fewer children per node than the alphabet allows. The empty slots burn cache lines and RAM for nothing.
Viktor Leis and colleagues solved this in their 2013 paper by introducing four node sizes — Node4, Node16, Node48, Node256 — each tuned to a different child count. A node grows when it fills up and shrinks when keys are deleted. The result is a trie that stays as compact as the data requires while still delivering lookup for a key of length — independent of how many keys the tree holds.
Comments
Loading comments...