In what best time complexity you can merge two max-heaps? (Assume size of first heap is (m+n) and the second is (n))
In what best time complexity you can merge two max-heaps? (Assume size of first heap is (m+n) and the second is (n))
@Shreya-Gupta-2383169445069382 Knowing that the time complexity to build a heap from an array with N elements is O(N) in best case…so for (m+n)+n elements, it should be O(m+2n)
So answer should be O(m+n).
1 Like
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.