A utility function to minheapify the node harr [ i ] of a heap stored in harr [ ]
def minHeapify ( harr , i , heap_size ) : NEW_LINE INDENT l = i * 2 + 1 NEW_LINE r = i * 2 + 2 NEW_LINE smallest = i NEW_LINE if l < heap_size and harr [ l ] . val < harr [ i ] . val : NEW_LINE INDENT smallest = l NEW_LINE DEDENT if r < heap_size and harr [ r ] . val = 0 : NEW_LINE INDENT minHeapify ( harr , i , n ) NEW_LINE i -= 1 NEW_LINE DEDENT DEDENT