0% found this document useful (0 votes)
80 views

Forest Trees

Forests consist of disjoint trees. An ordered forest has trees with a designated root node and significant node order, while a free tree lacks a root and node order is insignificant. An ordered forest can be converted to an equivalent binary tree and vice versa using natural correspondence, which links brothers from left to right and removes links from fathers except to the oldest son. Forests can be traversed in preorder and postorder by traversing each tree individually.

Uploaded by

Harold Costales
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
80 views

Forest Trees

Forests consist of disjoint trees. An ordered forest has trees with a designated root node and significant node order, while a free tree lacks a root and node order is insignificant. An ordered forest can be converted to an equivalent binary tree and vice versa using natural correspondence, which links brothers from left to right and removes links from fathers except to the oldest son. Forests can be traversed in preorder and postorder by traversing each tree individually.

Uploaded by

Harold Costales
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

FOREST TREES

Forests
When disjoint trees are taken together, they are known as a
forest.

If the trees comprising a forest are ordered trees, it


is known as ordered forest
Ordered Tree
An ordered tree is a finite set, say T, of one or more
nodes such that there is specially designated node called
the root.
In an ordered tree, the order of each node in the tree
is significant.
Free Tree
A free tree has no node designated as the root and
the orientation from a node to any other node is
insignificant.
Natural Correspondence
An ordered forest, say F, may be converted into a
unique binary tree, say B(F), and vice versa using a well-
defined process known as natural correspondence.

Natural correspondence may be implemented using non-recursive


approach:
1. Link together the sons in each family from left to right. (Note:
the roots of the tree in the forest are brothers, sons of an
unknown father.)
2. Remove links from a father to all his sons except the oldest (or
leftmost) son.
3. Tilt the resulting figure by 45 degrees.
Example
Example of Natural
Correspondence
Forest Traversal
Just like binary trees, forests can also be traversed.
However, since the concept of middle node is not defined,
a forest can only be traversed in preorder and postorder.

• • Preorder Traversal
• 1. Visit the root of the first tree.
• 2. Traverse the subtrees of the first tree in preorder.
• 3. Traverse the remaining trees in preorder.
• • Postorder Traversal
• 1. Traverse the subtrees of the first tree in postorder.
• 2. Visit the root of the first tree.
• 3. Traverse the remaining trees in postorder.
• Forest preorder : A B C D E F G H I K J L M N
• Forest postorder : C D E F B A H K I L J G N M

• The binary tree equivalent of the forest will result to the following listing for preorder,
inorder and postorder

• B(F) preorder : A B C D E F G H I K J L M N
• B(F) inorder : C D E F B A H K I L J G N M
• B(F) postorder : F E D C B K L J I H N M G A

You might also like