How Tarjan answers LCA queries offline

Short answer: Tarjan’s offline LCA answers a batch of lowest-common-ancestor queries during one depth-first search, using union-find. When the search finishes a node, the node is united with its parent and the parent’s set is labeled with the parent. A query between the finished node and a node already…

How Stoer-Wagner finds a global min-cut

Short answer: Stoer-Wagner computes a global minimum cut of an undirected weighted graph deterministically. Each phase grows a set like Prim, always adding the vertex most tightly connected to the set. The cut that separates the last vertex of the phase from the rest is a candidate. The phase…

How Shellsort chooses a gap sequence

Short answer: Shellsort insertion-sorts the array at a descending sequence of gaps and finishes with gap 1. An h-sorted array stays h-sorted when a later pass uses a smaller gap. The worst-case bound is a property of the gap sequence: Shell’s original halving sequence is Θ(n²), Hibbard’s 2^k−1 sequence…