本文共 1198 字,大约阅读时间需要 3 分钟。
理了一下八大排序(to do list好多年终于填掉了) 人是真的要锤大锤打才能成长起来哇~
舍友过生日,先撤了~
# - * - coding:utf8 - * - -'''@Author : Tinkle G@Creation Time: 2018/03/16'''class Solution(object): ######################## # 插入排序 ######################## # 直接插入排序 def StraightInsertionSort(self,nums): idx,size = 0,len(nums) while(idx=0): if tmp =1): for i in range(k,n): j = i-k tmp = nums[i] while(j>=0 and tmp nums[j+1]: nums[j+1],nums[j] = nums[j],nums[j+1] def BubbleSort1(self,nums): i = len(nums)-1 while(i>0): pos = 0 for j in range(i): if nums[j]>nums[j+1]: pos = j nums[j],nums[j+1]=nums[j+1],nums[j] i = pos def BubbleSort2(self,nums): start,end = 0,len(nums)-1 while(start nums[j+1]: nums[j],nums[j+1] = nums[j+1],nums[j] end -=1 for j in range(end,start,-1): if nums[j] =key): high-=1 nums[low],nums[high]=nums[high],nums[low] while(low
转载地址:http://rfqmi.baihongyu.com/