Answer the question
In order to leave comments, you need to log in
Why does heapSort run in n log N?
I have a heap its height is log n. I want to sort it, n is the case not the number of vertices that need to be sorted?
Answer the question
In order to leave comments, you need to log in
N is the number of elements in the heap, when sorting, you need to get all the elements from the heap one by one, after each extraction, the heap must be rebuilt, this requires O (logN) operations.
The total is O(NlogN).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question