If k = N, and we record the deleteMin elements as they come off the heap, we will have essentially sorted the N elements. We will refine this idea to obtain a fast sorting algorithm called heapsort
1. Class No.27 Data Structures http://ecomputernotes.com
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
Notas do Editor
Start of lecture 33
buildHeap is O ( N ) operation. Each deleteMin is O (log 2 N ). The total running time is thus O ( N + k log 2 N ). If k is small, or O ( N / log 2 N ), then the time required is O ( N ).