Question: Write the function merge BSTs (t1,t2) that receives binary search trees t1 and t2 and determines if they can be merged by adding a reference

 Write the function merge BSTs (t1,t2) that receives binary search trees

Write the function merge BSTs (t1,t2) that receives binary search trees t1 and t2 and determines if they can be merged by adding a reference from a node in t1 to the root of t2 while maintaining the binary search tree property. If merging the trees is possible, your function should merge them, with the root of the merged tree being t1, if that is not possible, the function should do nothing. For example, for the trees below, merge BSTs(t0,t1) should transform t0 into t3, since the merge is possible, and merge BSTs(t0,t2) should leave t0 unchanged, since the merge is not possible

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!