In insertion in heap

is the time complexity-O(nlogn)
because we are using upheafiy

Hey @shashankmaheshwari054 the worst case, the time complexity of inserting a node in a heap would be O(logN). And best case for insertion will be O(1)
When inserting a new element, we add it at the bottom of the heap tree, and move up the tree while comparing to the current parent element and swapping if needed. Because we move up for heapify up, we only make one comparison per iteration, between the current element and its parent element.

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.