A utility function to minheapify the node harr [ i ] of a heap stored in harr [ ]
void minHeapify ( HeapNode harr [ ] , int i , int heap_size ) { int l = i * 2 + 1 ; int r = i * 2 + 2 ; if ( l < heap_size && r < heap_size && harr [ l ] . val < harr [ i ] . val && harr [ r ] . val < harr [ i ] . val ) { HeapNode temp = harr [ r ] ; harr [ r ] = harr [ i ] ; harr [ i ] = harr [ l ] ; harr [ l ] = temp ; minHeapify ( harr , l , heap_size ) ; minHeapify ( harr , r , heap_size ) ; } if ( l < heap_size && harr [ l ] . val < harr [ i ] . val ) { HeapNode temp = harr [ i ] ; harr [ i ] = harr [ l ] ; harr [ l ] = temp ; minHeapify ( harr , l , heap_size ) ; } }