Advanced Placement Computer Science AB:
Assignment 34:  Heaps and HeapSort
  Sewickley Academy, 2000-2001

See Course Home Page.
 
Date Assigned: Fri Feb-16
Date Due: Wed Feb-21

0.  Prepare for a quiz on Wed Feb-21 on Heaps and HeapSort.

1.  Write a class, Heap, which exposes a static void method Heap::HeapSort(apvector<itemType>& v).  Note that you may assume that itemType has a less-than (<) operator, so your function could be called with an apvector<int> and an apvector<apstring> but not with an apvector<char*>.

Also, note that your HeapSort must sort in-place, meaning that it must not allocate a new vector, but instead must directly modify the vector v.

Demonstrate that your class works by creating a random vector of doubles (not integers) -- ie, an apvector<double> -- then print out the random vector, call Heap::HeapSort, and print out the resulting sorted vector.

Good luck!


DK



See Course Home Page.