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.10-1

Exercise 1.2.10-1

not stated yet 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.10 of Volume 1. Companion chapter: Analysis of an algorithm

The task

Find pn0p_{n0} from the recurrence (4) and the start (5), and say what it means for Algorithm M.

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

Put k=0k=0 in (4). The term with pn−1,−1p_{n-1,-1} vanishes by (5).

Hint 2

Multiply the resulting ratios.

Solution

Show the solution

For k=0k=0 Eq. (4) reads pn0=1npn−1,−1+n−1npn−1,0p_{n0}=\frac1np_{n-1,-1}+\frac{n-1}np_{n-1,0}. The first term is zero, because pnk=0p_{nk}=0 for k<0k<0. So pn0=n−1npn−1,0p_{n0}=\frac{n-1}np_{n-1,0} for n≥2n\ge2, and p10=1p_{10}=1. Then

pn0=n−1n⋅n−2n−1⋯12⋅p10=1n.p_{n0}=\frac{n-1}n\cdot\frac{n-2}{n-1}\cdots\frac12\cdot p_{10}=\frac1n.

The step M4 is not executed at all exactly when X[n]X[n] is the largest of the nn distinct keys. Each key is the largest with probability 1/n1/n when all orders are equally likely.

Check

For n=3n=3 the table of the six permutations has two cases with A=0A=0, so p30=13p_{30}=\frac13. A brute-force count over all permutations for n≤6n\le6 gives 1n\frac1n in each case.

Remarks

The same recurrence for Gn(z)G_n(z) gives Gn(0)=1/nG_n(0)=1/n directly from (7) and (8): Gn(0)=(n−1)!n!G_n(0)=\frac{(n-1)!}{n!}.

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

In Lean

not stated yet The exercise is not stated in Lean yet.

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

Something is wrong? Report it.