Which traversal should be used to print leaves of binary tree and why?

posted May 3

Boundary traversal should be used be used to print leaves of binary tree.In order to understand how boundary traversal works we should know about what is tree,binary tree,left node,right node etc.So let’s get started from the basics of tree:

A tree is one of the data structures which has one left node and one right node along with root.In other words,we can say that it has data,one node which points to left child and one another node which points to right child.It is a form of graphs which is used to inserting and deleting the elements of the tree.

A binary tree is one who has atmost only 2 children(left and right).The boundary traversal method plays a major role to print the leaves of binary tree.In this traversal,the boundary nodes of the tree will be printed in anticlockwise direction starting from the root with no duplicants.

Pseudo Code

1. Print root node.
2. Print left boundary in top-down manner except root and leaf nodes.
3. Print leaf nodes in inorder manner.
4. Print right boundary in bottom-up manner except root and leaf nodes.

This is the whole summary behind using boundary traversal for printing the leaves of the binary tree.

100 points
5