Short answer: A Fibonacci heap is a forest of heap-ordered trees with a cached minimum root. Insert, merge, and decrease-key are amortized O(1). Extract-min is amortized O(log n). Decrease-key cuts the node from its parent and marks the parent. A second cut on an already marked parent cascades. The…
Category: Heaps
How a binomial heap merges in logarithmic time
Short answer: A binomial heap is a forest of binomial trees, at most one tree of each order, like the binary representation of the heap’s size. Two trees of equal order link in constant time by hanging the root with the larger key under the other. Merging two heaps…
How a binary heap sifts in an array
Short answer: A binary heap stores a complete binary tree in an array. The parent of index i is floor((i−1)/2), and the children are 2i+1 and 2i+2, for zero-based indexes. The heap property says every parent is ordered before its children. Sift up repairs an insertion at the end.…
