public class Heap > { private Object H[]; // contains the objects in the heap private int last; // index of last element in heap private int capacity; // max number of elements in heap public Heap(int n){ capacity = n; H = new Object[capacity+1]; last = 0; } // // create a heap with capacity n // NOTE: H is an array of objects // must use casting when delivering the minimum // See min() below. // This must also be done in removeMin() // public Heap(){this(7);} // // by default, create a new heap with capacity 7 // @SuppressWarnings("unchecked") private int compare(Object x,Object y){return ((E)x).compareTo((E)y);} public int size(){return -999;} // // returns the number of elements in the heap // public boolean isEmpty(){return false;} // // is the heap empty? // @SuppressWarnings("unchecked") public E min() throws HeapException { if (isEmpty()) throw new HeapException("underflow"); return (E) H[1]; } // // returns element with smallest key, without removal // NOTE: must use casting to class (E) // public void insert(E e) throws HeapException { } // // inserts e into the heap // throws exception if heap overflow // @SuppressWarnings("unchecked") public E removeMin() throws HeapException { return null; } // // removes and returns smallest element of the heap // throws exception if heap is empty // NOTE: must cast result to class (E) // see min() above // public String toString(){ return "implement me"; } // // outputs the entries in H in the order H[1] to H[last] // in same style as used in ArrayQueue // // }