Step 1 : Do extract minimum k1 times ( This step takes O ( K1 Log n ) time )
for i in range ( 0 , k1 + 1 ) : NEW_LINE INDENT a [ 0 ] = a [ n - 1 ] NEW_LINE n -= 1 NEW_LINE minheapify ( a , 0 ) NEW_LINE DEDENT