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

Binary Tree to BST Conversion

Language Java | Level Intermediate | Category Data structure | September 8, 2015 7:54 am


Data structure Description

Write a program to convert Binary Tree to Binary Search Tree. The binary search tree left side node values are less than or equal to parent node and right side node values are greater than or equal to the parent node.


Output

   					 

All Binary Tree Values: 20  30  10  15  5  
Convert from Tree to Array:[20, 30, 10, 15, 5]
After sort the array: [5, 10, 15, 20, 30]
After convert from Binary Tree to Binary Search Tree Values: 5 10  15  20  30  

				    

Comments


No comments available!

Please login to add comments.