Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started