U
U
UID_B Nintendo2018-09-09 11:08:38
Algorithms
UID_B Nintendo, 2018-09-09 11:08:38

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

1 answer(s)
V
Vladimir Olohtonov, 2018-09-09
@sgjurano

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 question

Ask a Question

731 491 924 answers to any question