Assignment #8.

1.Implement a template <class Object> class BinaryHeap using an array of type Object. Rather than using the author's code, you must use upheap() and downheap() functions explained in the lecture. The largest should be on top.
2.Implement a new class PriorityQueue using the BinaryHeap, by composition.

3.Demonstrate your new PriorityQueue by implementing algorithm 6B for the “selection problem,” page 223 in the Weiss text. Note that this algorithm calls for a priority queue that has the smallest on top in order to find the kth largest integer. To achieve this, you have 2 choices: (a) you can revise PriorityQueue to put the smallest on top rather than the largest, not too clever, or (b) you can simply “complement” the integers by subtracting each from a big integer (bigger than any in the list you are working with). That is, in the priority queue simply save MAX_INT – a[i] instead of a[i] itself. Hint: you can do a more efficient implementation if you give your PriorityQueue class an additional public member function, called Look(), that  returns the highest priority item without deleting it. Otherwise, you will be doing lot of unnecessary removal and reinsertion.