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-3

Exercise 1.2.10-3

not stated yet in Lean solution written

RatingM15
MarkersM (mathematical)
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

Give decimal values of the minimum, maximum, mean and standard deviation of AA for n=1000n=1000.

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

Use Eq. (16) with n=1000n=1000.

Hint 2

For the sum Hn−Hn(2)H_n-H_n^{(2)} use Hn(2)≈π2/6H_n^{(2)}\approx\pi^2/6.

Solution

Show the solution

By (16) the statistics of AA are (min⁡0, ave⁡Hn−1, max⁡n−1, dev⁡Hn−Hn(2))\bigl(\min0,\ \operatorname{ave}H_n-1,\ \max n-1,\ \operatorname{dev}\sqrt{H_n-H_n^{(2)}}\bigr). For n=1000n=1000:

H1000=7.485470…H_{1000}=7.485470\ldots, so the mean is 6.485470…≈6.496.485470\ldots\approx6.49.

H1000(2)=1.643934…−11000+⋯≈1.64393H^{(2)}_{1000}=1.643934\ldots-\frac1{1000}+\cdots\approx1.64393, so the variance is 7.48547−1.64393=5.841547.48547-1.64393=5.84154 and the standard deviation is 5.84154=2.4169…≈2.42\sqrt{5.84154}=2.4169\ldots\approx2.42.

The minimum is 00 and the maximum is 999999.

Check

Python gives H1000−1=6.4854709H_{1000}-1=6.4854709 and H1000−H1000(2)=2.4169270\sqrt{H_{1000}-H_{1000}^{(2)}}=2.4169270.

Remarks

The mean grows like ln⁡n\ln n, so the step M4 is rare. The maximum n−1n-1 is reached only for the one decreasing input.

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.