A ladder lottery, known as the “Amidakuji” in Japan, is a common way to choose an assignment randomly. Formally, a ladder lottery of a permutation π = (p1, p2, . . . , pn) is a network with n vertical lines (lines for short) and many horizontal lines (bars for short) as follows (see Fig. 1). The i-th line from the left is called line i. The top ends of the n lines correspond to π. The bottom ends of the n lines correspond to the identical permutation (1, 2, . . . , n). Each bar connects two consecutive lines. Each number pi in π starts at the top end of line i, and goes down along the line, then whenever pi comes to an end of a bar, pi goes horizontally along the bar to the other end, then goes down again. Finally pi reaches the bottom end of line pi. We can regard a bar as a modification of the “current” permutation. In a ladder lottery a sequence of such modifications always results in the identical permutation (1, 2, . . . , n). The ladder lotteries are strongly related to primitive sorting networks, which are deeply investigated by Knuth [2]. A comparator in a primitive sorting network replaces pi and pj by min (pi, pj) and max (pi, pj), while a bar in a ladder lottery always exchanges them. Given a permutation π = (p1, p2, . . . , pn) the minimum number of bars to construct ladder lotteries of π is equal to the number of “reverse pairs” in π, which are pairs (pi, pj) in π with pi > pj and i < j. A ladder lottery of π with the minimum number of bars is optimal. The ladder lottery in Fig. 2 has eight bars, and its corresponding permutation (2,6,4,1,5,3) has eight reverse pairs: (2,1), (6,4), (6,1), (6,5), (6,3), (4,1), (4,3) and (5,3), so the ladder lottery is optimal. In [5] we gave an algorithm to enumerate all optimal ladder lotteries of a given permutation π. The algorithm generates all optimal ladder lotteries of π in O(1) time for each. The idea of our algorithm in [5] is as follows. We first define a tree structure Tπ, called the family tree, among optimal ladder lotteries, in which each vertex of Tπ corresponds to each optimal ladder lottery and each edge of Tπ corresponds to a relation between two optimal ladder lotteries. Then we design an efficient algorithm to generate all child vertices
Read full abstract