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

Exercise 1.2.10-19

not stated yet in Lean solution written

RatingM21
MarkersM (mathematical)
KindK1, prove: show that a stated fact is true from the written solution
SectionSection 1.2.10 of Volume 1. Companion chapter: Analysis of an algorithm

The task

Show that aka_k is a left-to-right maximum of a permutation exactly when kk is a right-to-left minimum of the inverse permutation.

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

Write the condition for aka_k with l=akl=a_k, and rewrite it with the inverse bb in place of aa.

Solution

Show the solution

Let ak=la_k=l, so bl=kb_l=k. All values are distinct. The element aka_k is a left-to-right maximum when aj<la_j<l for all j<kj<k. We rewrite this condition step by step.

  1. Every j<kj<k has aj<la_j<l if and only if every jj with aj>la_j>l has j>kj>k (the value aj>la_j>l cannot sit at j<kj<k, and j≠kj\ne k since ak=la_k=l).
  2. Put l′=ajl'=a_j. The values l′>ll'>l are exactly the values aja_j with aj>la_j>l, and j=bl′j=b_{l'}. So the condition says: every l′>ll'>l has bl′>kb_{l'}>k.
  3. Since k=blk=b_l, this says that bl′>blb_{l'}>b_l for all l′>ll'>l, which means that bl=kb_l=k is smaller than all the entries to its right. That is, kk is a right-to-left minimum of b1…bnb_1\ldots b_n.

Each step is an equivalence, so the two conditions agree.

Check

Take a=2 4 1 3a=2\,4\,1\,3. The left-to-right maxima are at the positions k=1k=1 and k=2k=2 (the values 22 and 44). The inverse is b=3 1 4 2b=3\,1\,4\,2. Its right-to-left minima are the entries 11 (at place 22) and 22 (at place 44), so the set of values {1,2}\{1,2\} is the set of positions kk found for aa.

Remarks

A left-to-right maximum of aa is a record, and the number of records is the quantity in the text. The bijection shows that the records of aa and of a−1a^{-1} (as minima) have the same count.

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.