Heap runtime when all elements are identical

Can we say that when all elements are identical in an array A of size n, then the runtime of the sort heap is O (n)

-> If so, Is O (n) best heapsort runtime

+5
source share
1 answer

When all elements are equal in height, the heap takes O (n) steps. Since when an element is added to the heap after O (1) comparison, we see that it is in the correct position.

Removing the root is also O (1), when we swap the tail and the root, the heap property is still satisfied.

O (n) O (n). , , heapsort O (n). , heapsorts O (n).

' Heapsorts O (n)' - - : n, k * n, . , , .

+5

All Articles