Loading…
Play, pause, and step through classic algorithms — with real source code in multiple languages, right in your browser.
Tracks a partition of elements into disjoint sets, with near-constant-time union and connectivity queries thanks to union-by-rank and path compression.
A complete binary tree kept in an array where every parent outranks its children. Insert sifts up and extract-max sifts down — both in O(log n).
A tree keyed by characters where words sharing a prefix share a path. Insert and lookup both run in O(L), the length of the word — independent of how many words are stored.
A binary tree of interval aggregates (here, sums) that answers any range query in O(log n) by combining a handful of covering nodes instead of scanning the array.