1.冒泡排序,相邻位置比较大小,将比较大的(或小的)交换位置 def maopao(a): for i in range(0,len(a)): for j in range(0,len(a)-i-1): if a[j]>a[j+1]: temp = a[j+1] a[j+1] = a[j] a[j] = temp #pri…
一些常用的排序 #系统内置排序算法#list.sort()#heapq模块 def sys_heap_sort(list): import heapq heap = [] for i in range(len(list)): heapq.heappush(heap,list[i]) for i in range(len(heap)): list[i] = heapq.heappop(heap) #python操作列表的方法,它们的时间复杂度 #insert() ---> O(n) #remov…