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 · 2.3-6

Exercise 2.3-6

not stated yet in Lean solution written

Rating21
Markersrecommended
KindK1, prove: show that a stated fact is true from the written solution
SectionSection 2.3 of Volume 1

The task

Define for two nodes XX and YY of a tree the statement that XX is an mmth cousin of YY, nn times removed, for m≥0m \ge 0 and n≥0n \ge 0, in the way of family trees.

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 pk(X)p^k(X) for the kkth parent of XX. A sibling is a 0th cousin. A first cousin has the same grandparent.

Hint 2

Two conditions are needed: a common ancestor at a fixed distance, and a rule that says the lines of descent separate just below it.

Solution

Show the solution

Let p0(X)=Xp^0(X) = X and pk+1(X)=p(pk(X))p^{k+1}(X) = p(p^k(X)). The value pk(X)p^k(X) is undefined when XX has fewer than kk proper ancestors.

Definition. XX is an mmth cousin of YY, nn times removed, when both pm+1(X)p^{m+1}(X) and pm+n+1(Y)p^{m+n+1}(Y) exist and are equal, and pm(X)≠pm+n(Y)p^{m}(X) \ne p^{m+n}(Y).

The first condition says that XX and YY have a common ancestor WW that is m+1m+1 steps above XX and m+n+1m+n+1 steps above YY. The second condition says that the two lines of descent from WW down to XX and to YY use different children of WW. So WW is the nearest common ancestor.

Examples in a family tree. For m=0m = 0, n=0n = 0 the nodes are siblings. For m=1m = 1, n=0n = 0 they are first cousins. For m=0m = 0, n=1n = 1 the node XX is a sibling of the parent of YY, so XX is an aunt or uncle of YY. For m=1m = 1, n=1n = 1 the node XX is a first cousin of the parent of YY.

The relation is not symmetric when n>0n > 0, because YY is deeper than XX by nn levels. In ordinary speech the relation is treated as symmetric.

Check

Python3 applied the definition to the tree of Fig. 19. It found: HH is a first cousin of FF (m=1m = 1, n=0n = 0), DD and FF are siblings (m=0m = 0, n=0n = 0), BB is a 0th cousin of GG twice removed (m=0m = 0, n=2n = 2, so BB is a great-aunt or great-uncle of GG) and BB is an aunt or uncle of DD (m=0m = 0, n=1n = 1). Each pair satisfied exactly one pair (m,n)(m, n).

Remarks

Exercise 2.3-7 extends the definition so that every pair of nodes has exactly one (m,n)(m, 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.