PATRICIA Trie / Radix Tree

A trie with single-child chains compressed into string-labeled edges. Insert splits an edge where keys diverge; longest-prefix match (LPM) descends to the deepest matching stored key — the operation behind IP routing.

Insert / Search / LPM: O(L) Nodes: O(N) (≤ 2N−1) Longest-prefix match
Slow Fast
Internal
Terminal (stored key)
On path
Found
Diverged
New split node
LPM answer
Keys
0
Radix nodes
1
Plain-trie nodes
1
Saved
0%
Last op

Stored keys (sorted)

Trace

Insert keys to build the radix tree. Each edge is labeled with a whole string; inserting a diverging key splits an edge. Try Search and Longest prefix.

Complexity

OperationTimeNotes
Insert (with split)O(L)≤ 2 new nodes per insert
SearchO(L)independent of key count N
StartsWithO(L)prefix may end mid-edge
Delete (with merge)O(L)fuse single-child node back
Longest-prefix matchO(L)IP routing operation
Total nodesO(N)≤ 2N−1, key-length independent
Total spaceO(N + chars)vs O(chars×Σ) for plain trie

Operation log