University of California, Santa Cruz

Prof. Paulo Franca - Spring 2000

Introduction

Syllabus

Guidelines for labs

Lab sections

Take quiz & check grades

Procedure Heapsort

Explanation:

Build a heap with the given Array A
Extract element at top of the heap (and reheap)
Decrease the size of the heap
Store the element you removed right after the heap ends
Repeat this until heapsize is 2

Procedure:

Heapsort(A)
          BuildHeap(A)
for  i=A.lenght downto 2
     exchange A[1] with A[i]
     A.heapsize = A.heapsize - 1
    Heapify (A,1)

What is the running time?