Time complexity is O(N)

in this are we including the case where all the n elements will attach one after another as in like a skew tree

we are talking about heap here
and heaps are balanced binary tree because we use array to implement them

Inserting n elements into a heap one by one will take O(n∗logn) time. However, if we are given the n elements all at once we can build a heap from them in O(n) time.

1 Like

sir, so you are saying that if we have a heap of n elements and we have to add n more elements in it then at first we take as input all the n elements and then build again the heap and it will take O(2n)~O(n) time…???

yes…
this is good only if you want to merge two heaps

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.