Bhaiya help me this one

We have a binary heap on n elements and wish to insert n more elements (not necessarily one after another) into this heap. The total time required for this is

i did not get what does not necessarily one after other means

which ques are u referring to?? uska snippet bhejna

Q7. Build Heap 2

We have a binary heap on n elements and wish to insert n more elements (not necessarily one after another) into this heap. The total time required for this is

O(logN)

O(N)

O(NlogN)

O(N^2)

An insert operation on a binary heap takes O(logn) time, but an alternative approach we can use. which requires us to insert n elements in heap without any computation i.e. in constant time. after which we can apply Heapify operation(this operation creates heap in linear time) on the array of those element and Hence obtain a Heap in O(n) time.

1 Like

btw which college you are from ?

Thapar University CSE

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.