2.2 Subtree

A tree is very neat, as we can partition a portion of a tree, and the partition itself is a tree as well!

Using our formal notation, it means that Given a tree represented by (N,P), we can construct a smaller tree with some node n N as the root. Let us use the notation T((N,P),n) be the subtree of the tree (N,P) but rooted at node n. The new (potentially smaller) tree T((N,P),n) = (N,P) can be constructed as follows.

Nconsists of all the descendents of n and n itself. In other words, n Nand m N : A(n,m) m N. Pconsists of all the tuples in P such that the parent is in N. In other words, (a,b) P : (a N) ((a,b) P).

The special property of a tree (that we can take any node and its descendents, and see that as a tree) makes recursive methods very useful for trees.