private void heapifyUp ( int i ) { int iP = parent ( i ) ; while ( i != 0 && cmp ( i , iP ) < 0 ) //Should not be greater then our parent { swapHeapValues ( iP , i ) ; i = iP ; iP = parent ( i ) ; } }
Heapify up from the given index in the heap and make sure everything is correct . Stops when the child value is in correct order with its parent .