โ† Wiki Index / Computation & Algorithms / Quake Heap
๐Ÿ’ป Computation & Algorithms

Quake Heap

A quake heap is a tournament-tree priority queue invented by Timothy M. Chan that achieves the optimal amortized bounds of a Fibonacci heap without mark bits, cascading cuts, or ancestor rank updates during Decrease-Key, relying instead on global height-decay invariant checks during Delete-Min.

Quake Heap is a mergeable comparison-based priority queue data structure in computation and algorithms invented by Timothy M. Chan (circulated as a 2009 manuscript and published in Space-Efficient Data Structures, Streams, and Algorithms in 2013) that matches the optimal asymptotic time bounds of a Fibonacci heapโ€”O(1) worst-case time for Insert, Find-Min, Meld, and Decrease-Key, and O(log n) amortized time for Delete-Minโ€”without maintaining node mark bits, performing cascading cuts, or updating ancestor ranks during Decrease-Key. Instead of storing one node per element and readjusting local rank invariants along an ancestor path when a key decreases, a quake heap represents a priority queue as a forest of binary tournament trees in which each element x occupies a vertical path of cloned nodes from a leaf at level 0 up to its current tournament peak at height h(x).

Because Decrease-Key(x, k) simply severs the single pointer directly above the highest tournament node of x and updates the key of x in O(1) worst-case time without inspecting or modifying any ancestor nodes, repeated cuts can gradually thin out the lower levels of the tournament forest. To prevent tree heights from exceeding O(log n), Delete-Min checks a global exponential level-size decay condition ni+1 โ‰ค ฮฑ ni (for a fixed constant ฮฑ โˆˆ (1/2, 1), such as ฮฑ = 3/4) and triggers a top-down "quake" (earthquake) reconstruction that demolishes all tournament nodes above the lowest violating level i0 whenever upper levels become too sparse relative to their height.

Motivation and Elimination of Local Cut Bookkeeping

In classical priority queues designed for Dijkstra's algorithm and Prim's algorithm for minimum spanning trees, achieving O(1) amortized Decrease-Key alongside O(log n) Delete-Min requires bounding the maximum degree or height of every root tree by O(log n) even after an adversary cuts arbitrary subtrees from the interior of the trees:

  • In a Fibonacci heap, each node stores a Boolean mark bit recording whether it has already lost one child; losing a second child triggers a recursive cascading cut up the parent spine.
  • In a rank-pairing heap, only one cut occurs per Decrease-Key, but an upward pass must still walk parent pointers to decrement integer node ranks and maintain Type-1 or Type-2 rank-difference rules.
  • In a hollow heap, Decrease-Key avoids cutting edges by leaving a hollow node in place and introducing a second-parent pointer that turns the tree into a directed acyclic graph (DAG).

Timothy M. Chan observed that all local per-node bookkeeping during Decrease-Key can be eliminated if the invariant guaranteeing logarithmic tree height is enforced globally across entire height levels during Delete-Min, in direct analogy to scapegoat trees and global rebuilding techniques for deletion in static data structures.

Tournament-Tree Representation and Vertical Clone Paths

A quake heap stores a dynamic set of n elements inside a forest of rooted binary trees satisfying the structure of a knockout tournament:

  1. Leaves and Active Elements: Each stored element x is associated with a unique leaf node at level 0 (height 0).
  2. Vertical Path of Cloned Nodes: Whenever two roots u and v at height i are linked during a tournament match, a new parent node w is allocated at height i + 1 with left child u and right child v, and w is labeled as a clone of whichever child holds the smaller key (say, x). Consequently, every element x in the priority queue corresponds to a contiguous vertical chain of nodes from level 0 (its leaf) up to some peak level h(x) โ‰ฅ 0, where every node on the chain of x references the same underlying element x and shares its current key key(x).
  3. One-Child and Two-Child Internal Nodes: Initially, when a tournament node w is created at height i + 1 by linking two roots at height i, w has two children of height iโ€”one belonging to the vertical chain of the winning element x, and the other serving as the peak of the losing element y. If a subsequent Decrease-Key or Delete-Min severs the losing child y, w remains at height i + 1 with only one child (the node of x at height i). Thus, every node at level i > 0 has either one or two children at level i โˆ’ 1, and at least one of those children always represents the same element x as its parent.

Node Level Counts and Height Stratification

Unlike a pairing heap or splay tree where node depths fluctuate implicitly when subtrees are moved, the height (level) i of a tournament node in a quake heap is fixed at creation time and never changes for the lifetime of that node:

  • A leaf node always remains at level 0.
  • A node created by linking two level-i roots always remains at level i + 1 until it is destroyed during Delete-Min or demolished during a quake.
  • The data structure maintains a global array of integer counters n0, n1, n2, ..., nH, where ni denotes the total number of tournament nodes currently existing at level i across all trees in the forest (n0 = n).

Memory and Pointer Representation

Each tournament node u at level i stores a pointer to its underlying element item(u) = x, pointers to its left and right children at level i โˆ’ 1, and a parent pointer parent(u) at level i + 1, while the element record x stores key(x) and a pointer top(x) to the highest tournament node on x's vertical path (at level h(x)). Alternatively, in the compressed representation, each element x stores a linked list of the losing sibling roots defeated by x at levels 0, 1, ..., h(x) โˆ’ 1.

Core Priority Queue Operations

Find-Min, Insert, and Meld in O(1) Worst-Case Time

The quake heap maintains its tournament roots in a root list together with a pointer minRoot to the root holding the minimum key:

  • Find-Min(Q): Returns the element associated with minRoot in O(1) worst-case time.
  • Insert(x, k, Q): Allocates a leaf node for x at level 0 with key(x) = k and top(x) pointing to that leaf, increments n0 โ† n0 + 1, inserts the leaf into the root list, and updates minRoot if k < key(minRoot) in O(1) worst-case time.
  • Meld(Q1, Q2): Concatenates the root lists of Q1 and Q2 and updates minRoot to the smaller of the two minimum roots in O(1) worst-case time.

Decrease-Key in O(1) Worst-Case Time via Single-Edge Severing

Suppose Decrease-Key(x, k, Q) decreases the key of element x to k < key(x). Let u = top(x) be the highest node on the vertical clone path of x (at level h(x)):

  1. Key Update: Set key(x) = k. Because every node on the vertical chain of x from level 0 to level h(x) references key(x) (and already defeated its sibling subtree at every level โ‰ค h(x)), lowering key(x) preserves the tournament ordering at every node on x's vertical path below u.
  2. Root Check: If u is already a root (parent(u) = null), update minRoot if k < key(minRoot).
  3. Single-Pointer Cut Above top(x): If u is not a root, let w = parent(u) be the tournament node at level h(x) + 1 where x previously lost a tournament match. Detach u from w by clearing the child pointer of w that pointed to u and setting parent(u) = null. Insert u as a new tournament tree root at level h(x) in the root list, and update minRoot if k < key(minRoot).

No ancestor of w, no level counter ni, and no sibling subtree is touched, so Decrease-Key executes in O(1) worst-case time.

Delete-Min, Pairwise Root Linking, and the Global Quake Operation

When Delete-Min(Q) is called on a non-empty quake heap, let x be the minimum element located at minRoot:

  1. Vertical Path Removal: Delete the vertical chain of tournament nodes belonging to x from level h(x) down to its leaf at level 0. For each level i โˆˆ {0, 1, ..., h(x)}, decrement ni โ† ni โˆ’ 1, destroy the level-i node of x, and if that node had a surviving sibling child v at level i โˆ’ 1, promote v into the root list as a root at level i โˆ’ 1.
  2. Tournament Consolidation (Pairwise Linking by Level): Group all current tournament roots by their fixed level i โˆˆ {0, 1, ..., H}. Iterating from i = 0 upward: while at least two roots u and v exist at level i, remove u and v from the root list, compare their keys, allocate a new parent tournament node w at level i + 1 as a clone of the winner with children u and v, increment ni+1 โ† ni+1 + 1, and place w into the bucket of roots at level i + 1.
  3. Global Quake Check (Exponential Decay Enforcement): For a fixed decay constant ฮฑ โˆˆ (1/2, 1), typically ฮฑ = 3/4, scan the level counters n0, n1, ..., nH from i = 0 upward to test the height-decay invariant:

ni+1 โ‰ค ฮฑ ยท ni When every level i satisfies ni+1 โ‰ค ฮฑ ni, the maximum non-empty level H satisfies n ยท ฮฑH โ‰ฅ 1, so H โ‰ค log1/ฮฑ n = O(log n). If some level violates the condition, let i0 be the smallest index such that ni0+1 > ฮฑ ni0, and trigger a quake at level i0: destroy all tournament nodes at every level i > i0 (resetting ni = 0 for all i > i0) so that every node at level i0 whose parent was destroyed becomes a tournament root at level i0.

Amortized Analysis and Potential Function

A fresh tournament link at level i creates one parent node at level i + 1 from two children at level i, establishing a 1-to-2 ratio (ni+1 โ‰ค 0.5 ni). For the ratio ni+1 / ni to deteriorate from โ‰ค 0.5 to > ฮฑ (such as > 0.75), at least (2 โˆ’ 1/ฮฑ) ni+1 degree-1 nodes must have been created at level i0 + 1 by Decrease-Key cuts or Delete-Min deletions since level i0 was last rebuilt.

Define the potential function ฮฆ = c1 ยท R + c2 ยท D1, where R is the total number of tournament roots and D1 is the total number of degree-1 internal nodes across all levels:

  • Insert increases R by 1 (O(1) amortized cost), and Decrease-Key increases R by at most 1 and D1 by at most 1 (O(1) amortized cost).
  • During Delete-Min, removing the minimum element's vertical path of height H โ‰ค log1/ฮฑ n adds at most H roots (O(log n) potential increase), pairwise linking pays for itself via the drop in R, and when a quake occurs at the lowest violating level i0, the total number of demolished nodes above i0 is bounded by the geometric series โˆ‘i > i0 ni โ‰ค ni0+1 / (1 โˆ’ ฮฑ), which is paid for by eliminating the > (2 โˆ’ 1/ฮฑ) ni0+1 degree-1 nodes at level i0 + 1 from D1.
  • Furthermore, because n0 = n and ni+1 โ‰ค ฮฑ ni after every Delete-Min, total space is bounded by โˆ‘ ni โ‰ค n / (1 โˆ’ ฮฑ) = O(n) (at most 4n nodes for ฮฑ = 3/4).
Priority Queue Data StructureFind-MinInsertMeldDecrease-KeyDelete-MinHeight / Degree Maintenance Mechanism
Fibonacci HeapO(1)O(1)O(1)O(1) amortizedO(log n) amortizedPer-node mark bits + recursive cascading cuts during Decrease-Key
Rank-Pairing HeapO(1)O(1)O(1)O(1) amortizedO(log n) amortized1 cut + upward ripple of local 1-byte rank decrements during Decrease-Key
Hollow HeapO(1)O(1)O(1)O(1) amortizedO(log n) amortizedItem vacates hollow node; second-parent pointer forms rooted DAG
Quake HeapO(1)O(1)O(1)O(1) worst-caseO(log n) amortizedZero ancestor updates on Decrease-Key; global level quake (ni+1 > ฮฑ ni) on Delete-Min
Pairing HeapO(1)O(1)O(1)O(22โˆš(log log n))O(log n) amortizedSelf-adjusting two-pass sibling pairing on Delete-Min; no ranks
Van Emde Boas TreeO(1)O(log log U)โ€”O(log log U)O(log log U)Recursive universe-halving summary trees over integer keys in [0 .. U โˆ’ 1]

Frequently Asked Questions

Why is it called a quake heap?

Timothy M. Chan named the structure a quake heap because its periodic rebuilding step during Delete-Min acts like a structural "earthquake": whenever cuts from Decrease-Key have eroded the lower levels of the tournament forest so that some upper level i0 + 1 contains more than a fraction ฮฑ of the nodes in level i0 (ni+1 > ฮฑ ni), all tournament nodes above level i0 are demolished at once, reducing the surviving trees back to height i0.

How does Decrease-Key in a quake heap avoid touching ancestors?

In a quake heap, each element x is represented by a vertical chain of cloned tournament nodes from level 0 up to level h(x). Lowering the key of x makes x even more competitive in every tournament match it already won at levels โ‰ค h(x). The only match where x's new key could change the outcome is the match x lost at level h(x) + 1; severing the single pointer between top(x) and its parent at level h(x) + 1 detaches x's tournament subtree in O(1) worst-case time without visiting any higher ancestors.

What is the best choice for the decay parameter ฮฑ in a quake heap?

The decay parameter ฮฑ must satisfy 1/2 < ฮฑ < 1. If ฮฑ were โ‰ค 1/2, even a freshly linked complete binary tournament tree (where ni+1 = ni / 2) would trigger a quake; if ฮฑ were โ‰ฅ 1, tree heights would not be bounded by O(log n). Choosing ฮฑ = 3/4 balances the maximum tree height log4/3 n โ‰ˆ 2.41 log2 n against the frequency of quakes, ensuring that a quake at level i0 only occurs after at least half of the nodes at level i0 + 1 have lost a child.

References

  1. Chan, T. M. (2013). "Quake Heaps: A Simple Alternative to Fibonacci Heaps." In A. Brodnik, A. Lรณpez-Ortiz, V. Raman, & A. Viola (Eds.), Space-Efficient Data Structures, Streams, and Algorithms: Papers in Honor of J. Ian Munro on the Occasion of His 66th Birthday, Lecture Notes in Computer Science, vol. 8066, pp. 27โ€“32. Springer. https://doi.org/10.1007/978-3-642-40273-9
  2. Fredman, M. L., & Tarjan, R. E. (1987). "Fibonacci Heaps and Their Uses in Improved Network Optimization Algorithms." Journal of the ACM, 34(3), 596โ€“615. https://doi.org/10.1145/28869.28874
  3. Haeupler, B., Sen, S., & Tarjan, R. E. (2011). "Rank-Pairing Heaps." SIAM Journal on Computing, 40(6), 1463โ€“1485. https://doi.org/10.1137/100785351
  4. Hansen, T. D., Kaplan, H., Tarjan, R. E., & Zwick, U. (2017). "Hollow Heaps." ACM Transactions on Algorithms, 13(3), Article 42, 1โ€“27. https://doi.org/10.1145/3093240
  5. Elmasry, A. (2010). "The Violation Heap: A Relaxed Fibonacci-Like Heap." Discrete Mathematics, Algorithms and Applications, 2(4), 493โ€“503. https://doi.org/10.1142/S1793830910000838
๐Ÿงฌ Support Open Science
Explore interactive science games on LowKey Games or browse scientific apparel & accessories in the CRV Science Shop.
๐Ÿ’ก Spot an inaccuracy or have primary literature to expand this article?
Submit a citation or revision note using your shared CRV Science / LowKey Games profile ID.
Suggest Revision