Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves. Alan Kay

Print All paths

Language Java | Level Intermediate | Category Data structure | September 6, 2015 8:37 am


Data structure Description

Binary search tree can be traversed using in-order, pre-order and post order.

Pre-order:

Display the data of root node, Traverse left subtree recursively, Traverse right subtree recursively.

In-order:

Traverse left subtree recursively, Display the data of root node, Traverse right subtree recursively.

Post-order:

Traverse left subtree recursively, Traverse right subtree recursively, Traverse right subtree recursively.

Write a program to print all the paths from the root node to leaf nodes.


Output

   					 

All Binary Tree Values: 1 2  3  4  
Print the Tree values using in order: 1, 2, 3, 4, 
Print the Tree values using Preorder: 2, 1, 3, 4, 
Print the Tree values using Post order: 1, 4, 3, 2,

				    

Comments


No comments available!

Please login to add comments.