- #1
trouty323
- 24
- 0
Hello. The method here is to add an item to a heap. As the title states, I am getting the error "The operator > is undefined for the argument type(s) E, E" in the parenthesis after the while. I assume this is not the correct way to compare E values. Does anybody know what would be the correct way?
Code:
public boolean add(E item) {
data[size] = item;
child = size - 1;
parent = (child-1) / 2;
while (parent >= 0 && data[parent] > data[child]) {
// swap data[parent] and data[child]
child = parent;
parent = (child - 1) / 2;
}
}