1 votes 1 votes Design an algorithm to construct one heap that contains all the elements of two given heaps of sizes n and m, respectively. The heaps are given in a linked-list representation ( each node has links to its two children). The running time of the algorithm should be O(log(m + n)) in the worst case Algorithms algorithms heap time-complexity + – jola asked Dec 5, 2022 retagged Dec 5, 2022 by makhdoom ghaya jola 411 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
0 votes 0 votes We take the last element of one of the heaps and add it to the root and connect the two heaps to it. Now apply heapify on the resulting tree which takes O(log(m+n)) (in the worst case) to settle the root to its correct position. nishantsharma answered Jan 11, 2023 nishantsharma comment Share Follow See all 0 reply Please log in or register to add a comment.