Tries and union-find
Prefix trees for words and disjoint sets for grouping connected items.
- Tries: insert, search, prefix A trie stores words character by character along edges, with markers where words end. Insert, search and prefix queries take time…
- Trie applications: autocomplete, word search, XOR maximum Tries power autocomplete, word search on a grid, word replacement and the maximum XOR of two numbers.
- Disjoint set union: find, union, rank, path compression Union-find tracks which items are in the same group. Parent arrows point toward a root, and path compression flattens them for…
- Union-find applications: connectivity, grouping, redundant edges Add edges one by one and union-find merges components, revealing connectivity, groups and the edge that creates a cycle.