In-class group project? Implement a heap that extends AbstractHeap and implements Heapish; i.e.
public class Heap extends AbstractHeap implements Heapish {...}
Where those are defined as:
public interface Heapish {
public void insert(int x);
public int removeRoot();
public boolean isEmpty();
}
abstract class AbstractHeap {
static final int MAX = 100;
protected int[] list = new int[MAX]; // the tree (so to speak)
protected int insertIndex=1; // Next insert index - 0 is not used!
AbstractHeap(){} // to avoid errors in Heap constructors
int parent(int currentIndex) {
return currentIndex / 2;
}
int leftChild(int currentIndex) {
return currentIndex * 2;
}
int rightChild(int currentIndex) {
return leftChild(currentIndex) + 1;
}
}