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

Exercise 2.3-17

not stated yet in Lean solution written

Rating01
KindK3, find a value: compute a number, a set or a closed form from the written solution
SectionSection 2.3 of Volume 1

The task

The forest ZZ is Fig. 19 regarded as a forest. Find the node parent(Z[1,2,2])\mathrm{parent}(Z[1,2,2]).

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

Compute Z[1]Z[1], Z[1,2]Z[1,2] and Z[1,2,2]Z[1,2,2] one index at a time. Each index selects a subtree and then takes its list of subtrees.

Solution

Show the solution

The forest ZZ has one tree, with root AA. Then Z[1]Z[1] is the forest of subtrees of AA, namely the trees with roots BB and CC. The second subtree is the tree of CC. So Z[1,2]Z[1,2] is the forest of the subtrees of CC, namely the trees with roots DD, EE and FF. The second subtree there is the tree of EE. So Z[1,2,2]Z[1,2,2] is the forest of subtrees of EE, which is the single tree with root GG. The parent of this forest is the node EE.

Answer: EE.

Check

The chain parent(Z[1])=A\mathrm{parent}(Z[1]) = A, parent(Z[1,2])=C\mathrm{parent}(Z[1,2]) = C, parent(Z[1,2,2])=E\mathrm{parent}(Z[1,2,2]) = E matches the Dewey numbers 11, 1.21.2, 1.2.21.2.2 of AA, CC, EE in the tree of Fig. 19. Python3 followed the same indices in a nested-list encoding of Fig. 19 and got EE.

Remarks

The indices 1,2,21, 2, 2 are the Dewey number of the answer.

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.