As soon as we started programming, we found to our surprise that it wasn’t as easy to get programs right as we had thought. Debugging had to be discovered. I can remember the exact instant when I realized that a large part of my life from then on was going to be spent in finding mistakes in my own programs. Maurice Wilkes

Print BST

Language Java | Level Intermediate | Category Data structure | August 30, 2015 1:27 pm


Data structure Description

A binary search tree is a rooted binary tree, whose internal nodes each store a key and each node has two distinguished sub-trees, left and right. The binary search tree property, which states that the key in each node must be greater than all keys stored in the left sub-tree, and smaller than all keys in right sub-tree. The stack is a data structure with last in first out (LIFO) insertion order. The Stack can use for traversing the tree without recursion.

Write a program to print the Binary search Tree nodes using stack operation.


Output

   					 

Insert [12,3,6] elements to Stack
Traverse the elements from Stack:
3
6
12


				    

Comments


No comments available!

Please login to add comments.