Algorithm Search⌘K

Proofs: Succinct permutation representation

These are the human proofs of Succinct permutation representation, at full length.

Correctness and step bound of the shortcut inverse full

This proof shows: correctness.

Fix ii, let C=(c0,c1,…,cL−1)C = (c_0, c_1, \ldots, c_{L-1}) be its cycle with ck+1=π(ck)c_{k+1} = \pi(c_k), indices mod LL, and let i=cai = c_a. The answer is π−1(i)=ca−1\pi^{-1}(i) = c_{a-1}.

Lemma 1 (the walk stays on the cycle). Every value of jj is an element of CC: initially j=ij = i, a forward step moves from ckc_k to ck+1c_{k+1}, and a shortcut moves from a marked cqtc_{qt} to c(q−1)tc_{(q-1)t} (or, for q=0q = 0, to the last mark cQtc_{Qt} with Q=⌈L/t⌉−1Q = \lceil L / t \rceil - 1), both on CC.

Lemma 2 (stopping). The loop stops exactly when Π[j]=i\Pi[j] = i, that is, when j=ca−1j = c_{a-1}, since π\pi is injective. So if it stops, it returns π−1(i)\pi^{-1}(i).

Short cycles (L≤tL \le t). No element of CC is marked, so the walk takes forward steps only: ca,ca+1,…c_a, c_{a+1}, \ldots, and reaches ca−1=ca+L−1c_{a-1} = c_{a + L - 1} after L−1L - 1 steps, with L≤tL \le t reads of Π\Pi.

Long cycles (L>tL > t). The marks are c0,ct,…,cQtc_0, c_t, \ldots, c_{Qt}, so between two consecutive marks along the cycle there are at most t−1t - 1 unmarked elements: the gaps are tt, except the last, from cQtc_{Qt} around to c0c_0, which is L−Qt≤tL - Qt \le t because QQ is the largest integer with Qt<LQt < L.

Phase 1. The walk goes forward from cac_a until it either stops at ca−1c_{a-1} or sits at a marked element cbc_b, with bb the first index at or after aa (cyclically) that is marked. This takes at most tt steps, since cbc_b is within t−1t - 1 positions of cac_a. If the predecessor ca−1c_{a-1} is met first, the loop stops (Lemma 2).

Phase 2. At cbc_b the walk takes the shortcut to the previous mark cb′c_{b'}. By the choice of bb, no element strictly between cac_a and cbc_b is marked, so the previous mark cb′c_{b'} is at or before ca−1c_{a-1}, cyclically: either b=ab = a and cb′c_{b'} is the mark before cac_a, or b≠ab \ne a and cb′c_{b'} is before cac_a because cac_a itself is unmarked. Its distance to ca−1c_{a-1} is less than the gap b−b′≤tb - b' \le t.

Phase 3. From cb′c_{b'}, forward steps reach ca−1c_{a-1} after at most t−1t - 1 steps, without passing cac_a, and the loop stops there. A mark met in this phase is passed by a forward step, because jumped is set.

In total, the walk reads Π\Pi at most tt times in phase 1, once after the jump, and at most t−1t - 1 more times in phase 3, plus the initial read: at most 2t+12t + 1 reads, so INVERSE takes O(t)O(t) time and always terminates.

Space. Each long cycle of length LL has Q+1=⌈L/t⌉≤L/t+1Q + 1 = \lceil L / t \rceil \le L/t + 1 marks and there are at most n/(t+1)n / (t + 1) long cycles, so ∣S∣≤n/t+n/(t+1)|S| \le n/t + n/(t+1). ■\blacksquare

Back to Succinct permutation representation