taocp

This site has no text of the book. Keep your own copy of TAOCP next to it. See what is checked.

Exercise · Volume 1 · 1.2.5-3

Exercise 1.2.5-3

proved in Lean solution written

Rating10
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 1.2.5 of Volume 1. Companion chapter: Permutations and factorials

The task

Apply the two methods of the section to the permutation 3 1 2 43\,1\,2\,4 and list the five permutations of {1,2,3,4,5}\{1,2,3,4,5\} that each method gives.

The exact wording is in your copy of the book.

Hints

Open one hint at a time. Try the exercise again after each.

Hint 1

Method 1 inserts the new largest number in every place. Method 2 adds a new last element kk and renames.

Hint 2

For Method 2 take k=1,2,3,4,5k = 1, 2, 3, 4, 5 in turn. Add 11 to each old entry that is at least kk, then write kk at the right end.

Solution

Show the solution

Method 1 inserts the number 55 at the five places of 3 1 2 43\,1\,2\,4, from the left end to the right end:

5 3 1 2 4,3 5 1 2 4,3 1 5 2 4,3 1 2 5 4,3 1 2 4 5.5\,3\,1\,2\,4,\quad 3\,5\,1\,2\,4,\quad 3\,1\,5\,2\,4,\quad 3\,1\,2\,5\,4,\quad 3\,1\,2\,4\,5.

Method 2 takes k=1,…,5k = 1, \ldots, 5. Entries that are at least kk go up by 11, and kk is appended.

kk old entries after the raise result
1 4 2 3 54\,2\,3\,5 4 2 3 5 14\,2\,3\,5\,1
2 4 1 3 54\,1\,3\,5 4 1 3 5 24\,1\,3\,5\,2
3 4 1 2 54\,1\,2\,5 4 1 2 5 34\,1\,2\,5\,3
4 3 1 2 53\,1\,2\,5 3 1 2 5 43\,1\,2\,5\,4
5 3 1 2 43\,1\,2\,4 3 1 2 4 53\,1\,2\,4\,5

Both lists have five permutations of {1,2,3,4,5}\{1,2,3,4,5\}, as the rule p5=5 p4p_5 = 5\,p_4 requires.

Check

A short program for each method gives the same two lists. Each of the ten rows is a permutation of {1,2,3,4,5}\{1,2,3,4,5\}, and the five rows of one method are different. The last row of both methods is 3 1 2 4 53\,1\,2\,4\,5: for Method 1 the number 55 goes to the right end, and for Method 2 the value k=5k = 5 raises nothing.

Remarks

The two lists share only 3 1 2 5 43\,1\,2\,5\,4 and 3 1 2 4 53\,1\,2\,4\,5. Method 1 gives the permutations that become 3 1 2 43\,1\,2\,4 when 55 is removed. Method 2 gives those whose first four entries are in the same relative order as 3 1 2 43\,1\,2\,4.

This solution is checked, and a person has not reviewed it yet. The source.

In Lean

proved The statement and its proof are in Lean. The kernel accepts the proof, and it uses the standard axioms only. Lean states the parts one by one.

The status is computed from the Lean build. The node of the map.

Something is wrong? Report it.