I have the workings of a percolateDown method but it doesn't totally work because the operator < is undefined for the argument type(s) E and E. I was wondering if I could get some advice on how to compare the three statements I have that are using "<" and ">".
Thanks!
private E[] arr; //instance variable
private int size; //instance variable
private void percolateDown(int index) {
if (index >= (size / 2) && index <= size)
return;
if (arr[index] < arr[leftChildIndex(index)] ||
arr[index] < arr[rightChildIndex(index)]) {
if (arr[leftChildIndex(index)] > arr[rightChildIndex(index)]) {
swap(index, leftChildIndex(index));
percolateDown(leftChildIndex(index));
} else {
swap(index, rightChildIndex(index));
percolateDown(rightChildIndex(index));
}
}
}