Hey everyone. I am attemtping to build a heap. The problem with

this code is that if the heap is not the max size, the last element

is not percolated up. Any ideas how to fix this code to do that?

Thanks.Code:void BinaryHeap::heapify( int i ) { int l, r, smallest; l = left( i ); // zero if no child r = right( i ); // zero if no child if( l <= size && array[l - 1] < array[i - 1] ) { smallest = l; } else { smallest = i; } if( r <= size && array[r - 1] < array[smallest - 1] ) { smallest = r; } if( smallest != i ) { int temp = array[i - 1]; array[i - 1] = array[smallest - 1]; array[smallest - 1] = i; array[smallest - 1] = temp; heapify(smallest); } } // end method heapify