Exercise · Volume 1 · 1.2.10-18
Exercise 1.2.10-18
not stated yet in Lean solution written
| Rating | M28 |
|---|---|
| Markers | M (mathematical) |
| Kind | K1, prove: show that a stated fact is true from the written solution |
| Section | Section 1.2.10 of Volume 1. Companion chapter: Analysis of an algorithm |
The task
Find the generating function of when the keys contain copies of the value for (with ) in random order.
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
is the number of right-to-left maxima of the sequence.
Hint 2
Build the sequence by placing the copies of first, then those of among them, and so on.
Hint 3
Find when a new value adds a right-to-left maximum.
Solution
Show the solution
Call a position a right-to-left maximum when for all . Position is always one. Step M4 runs once for each right-to-left maximum other than position , so , where is the number of right-to-left maxima.
All distinct arrangements of the multiset are equally likely. Build an arrangement in stages : at stage the copies of are put among the entries with values greater than , which are already in place. Look at the sequence of the entries with value only. It is a uniformly random arrangement of its multiset, and the positions of the copies of in it are a uniformly random choice of places out of places.
Smaller values do not change which larger entries are right-to-left maxima, because an entry is one only if all entries to its right are smaller. A copy of is a right-to-left maximum among the entries if and only if it is the last entry, since a copy of with any entry to its right (of value or more) is not strictly larger than all of them. So passing from the entries to the entries adds one right-to-left maximum exactly when the last place is occupied by a copy of . That has probability . The events for different are independent, because the relative placement of the 's among the larger entries does not depend on the arrangement of the larger entries. So is a sum of independent indicator variables, and the generating function of is
with for larger than all present values. The factor for the largest value present is (probability ). Since , we divide by :
If this is the product over , with the factor equal to instead of .
Check
For all the factor for is . The product over is , and dividing by gives (8). For the formula gives . A count of all arrangements of the multiset in Python gives of them with , the same values.
Remarks
Here and the mean is . The case of all distinct keys is the main text, and the case of distinct values with random multiplicities is Exercise 1.2.10-7.
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.