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

Exercise 2.3-2

not stated yet in Lean solution written

Rating20
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

Count the different oriented trees on the three nodes AA, BB, CC. In an oriented tree the order of the subtrees of a node does not matter.

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

Start from the 12 ordered trees of exercise 1. Which of them become equal when the order of siblings is forgotten?

Solution

Show the solution

An oriented tree is an ordered tree in which the children of a node form a set. Two ordered trees give the same oriented tree exactly when they differ only in the order of the subtrees at some nodes.

In the 12 ordered trees of exercise 2.3-1, the only node with two children is a root with two one-node subtrees. For each of the 3 roots, the two orders B,CB, C and C,BC, B now give one tree. The two chains below each root stay different.

So each root gives 1+2=31 + 2 = 3 trees, and the total is 3⋅3=93 \cdot 3 = 9.

Answer: 9.

Check

A python3 program built the 12 ordered trees and mapped each to a form where the children are a set. It found 9 different forms. For n=1,2,3,4,5n = 1, 2, 3, 4, 5 it found 1,2,9,64,6251, 2, 9, 64, 625, which is nn−1n^{n-1}.

Remarks

The count nn−1n^{n-1} is the number of rooted labelled trees. Section 2.3.4.4 proves it.

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.