[algogeeks] merging 2 search trees

2011-01-21 Thread snehal jain
You are given two height balanced binary search trees T and T’, storing m and n elements respectively. Every element of tree T is smaller than every element of tree T’. Every node u also stores height of the subtree rooted at it. Using this extra information how can you merge the two trees in time

Re: [algogeeks] merging 2 search trees

2011-01-21 Thread nishaanth
Find the node in T which is the maximum(which is either the root or the rightmost in the right subtree). After finding this node, just make the right child of this node point to the root of T'. Correct me if i am wrong On Fri, Jan 21, 2011 at 2:43 PM, snehal jain learner@gmail.com wrote:

Re: [algogeeks] merging 2 search trees

2011-01-21 Thread Divya Jain
@ above height will not be balanced then On 21 January 2011 19:15, nishaanth nishaant...@gmail.com wrote: Find the node in T which is the maximum(which is either the root or the rightmost in the right subtree). After finding this node, just make the right child of this node point to the root