CPSC 221

buildHeap analysis, heapSort

(min)Heap: buildHeap

A B E L D H I U P N O W A B E L D H I U P N O W

Proof of solution to the recurrence:

Thm: buildHeap on an array of size \(n\)
runs in time ________.

Time is proportional to the sum of the
heights of all the nodes. Call it \(S(h)\).

\(S(h) =\)

\(S(0) =\)

Soln \(S(h) =\)

But running times are reported in terms of \(n\), the number of nodes…

(min)Heap: heapSort

A B E L D H I U P N O W A B E L D H I U P N O W

1


2


3

Running time?

Why do we need another sorting algorithm?

heapSort Explorer