Why doesn't my heapify work?

Dongsheng Ruan ruan at jcmills.com
Wed Feb 7 13:00:09 EST 2007


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] 





More information about the Python-list mailing list