I've tried to make a few different heapify functions, but none of them have worked. Why isn't this actually doing anything?
Code:void heapify(int array[], int i) {
int largest = 0;
int temp = 0;
int n = sizeof(array);
int l = left(i);
int r = right(i);
if (l <= n && array[l] > array[i]) {
cout << "\n\nHERE IS THE DAMN PROBLEM";
largest = l;
}
else {
cout << "\n\nOkay, the else statement is working.";
largest = i;
}
if (r <= n && array[i] > array[largest]) {
cout << "\n\nOkay, largest = r.";
largest = r;
}
if (largest != i) {
cout << "\n\nAlright, this got down to the last step.";
temp = array[i];
array[i] = array[largest];
array[largest] = temp;
heapify(array, largest);
}
}