Question: Suppose the internal nodes of two binary trees, T 1 and T 2 respectively, hold items that satisfy the heap-order property. Describe a method for
Suppose the internal nodes of two binary trees, T1 and T2 respectively, hold items that satisfy the heap-order property. Describe a method for combining these two trees into a tree T, whose internal nodes hold the union of the items in T1 and T2 and also satisfy the heap-order property. Your algorithms should run in time O(h1 +h2) where h1 and h2 are the respective heights of T1 and T2.
Step by Step Solution
3.54 Rating (158 Votes )
There are 3 Steps involved in it
The idea is to treat the two binary trees as the two subtrees of a heap that has its greatest elemen... View full answer
Get step-by-step solutions from verified subject matter experts
