in this question we have to merge another heap of n elements and inserting one element takes O(log n) time
so inserting n elements wouldd take O(m+n log n ) time??
Ehy it is not O(Nlog(M+N))
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.