归并排序

归并排序 

arr=[12,88,1,2,5,23,41,56,7,108,72,342,23,33,74,25,6,7,5,33,72,9]

def MergeSort(a,start,end):
    print( a,start,end,a[start:end] )
    mid = (end + start) // 2
    if(end-start<=2 ):
        if(a[start]> a[end - 1]):
            a[start], a[end - 1] = a[end - 1], a[start]
        return
    else:
        MergeSort(a,start,mid)
        MergeSort(a,mid,end )


    for t in range(mid,end):
        for r in range(t-1,start-1,-1):
            if(a[r+1]

 

你可能感兴趣的:(python)