Let A1 and A2 be two BST (Binary Search trees) such that every key in A1 is smaller than every key in A2. You are given two pointers a1 and a2 to the roots of A1 and A2, respectively. Devise an algorithm that merges A1 and A2 into a single BST in O(min{h1,h2}) time, where h1 and h2 are the heights of A1 and A2.
1.4m articles
1.4m replys
5 comments
56.9k users