I want to turn an Array into a heap, but my code just doesn't work: no change after execution.
A=[3,5,4,9,6,7] m=len(A)-1 for i in range(m,1): t=(i-1)/2 if A[i]>A[t]: A[i],A[t]=A[t],A[i] -- http://mail.python.org/mailman/listinfo/python-list
I want to turn an Array into a heap, but my code just doesn't work: no change after execution.
A=[3,5,4,9,6,7] m=len(A)-1 for i in range(m,1): t=(i-1)/2 if A[i]>A[t]: A[i],A[t]=A[t],A[i] -- http://mail.python.org/mailman/listinfo/python-list