bhaiya said that the complexity of building a heap is O(n). but i think its O(nlogn) because insertion of one element takes O(logN) time.
am i right?
Complexity of building a heap
@sirraghavgupta Yes you are right. But we can say that in average case, the complexity of building a heap is O(n). Refer this https://www.growingwiththeweb.com/data-structures/binary-heap/build-heap-proof/
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.