Pages

Tuesday, 19 January 2016

Insertion Sort

def insertion_sort(L) :
    for j in range(1,len(L)) :
        a=L[j]
        i=j
        while L[i-1]>a and i>=1 :
            L[i]=L[i-1]
            i-=1
        L[i]=a
        print "List after pass",j,":",L