冒泡排序,冒泡排序改进,插入排序的Python实现

import random
import time
i=[random.randint(1,100000) for j in range(1,1000)]
list (i)

def math1(i):#冒泡排序
    start=time.time()
    for j in range(1,999):
        for k in range(0,999-j):
            if i[k]i[j+1]:
                temp=i[j]
                i[j]=i[j+1]
                i[j+1]=temp
            high-=1
        for j in range (high,low):
            if i[j]=0 and i[j]>temp:
            i[j+1]=i[j]
            temp2-=1
        i[temp2+1]=temp
    end=time.time()
    print("插入排序:",end-start)
    
if __name__ == '__main__' :math1(i)
if __name__ == '__main__' :math2(i)
if __name__ == '__main__' :math3(i)

   

              

               

       

你可能感兴趣的:(冒泡排序,冒泡排序改进,插入排序的Python实现)