Friday 6 July 2012

Merge Two Balanced Binary Search Trees

Solution:
Get the sorted values of both BSTs in O(m) + O(n), by doing in-order traversal of each BST.
Merge the two sorted arrays in O(m+n).
Create a balanced BST from sorted array in O(m+n).

http://www.geeksforgeeks.org/archives/18611

No comments:

Post a Comment