当前位置: 代码迷 >> 综合 >> 【python】python数据结构(六)——排序:插入排序
  详细解决方案

【python】python数据结构(六)——排序:插入排序

热度:83   发布时间:2023-12-16 22:49:50.0

算法说明

时间复杂度O(n^2)

不稳定

代码

# coding=utf-8
def insert_sort(lst):  for i in range(1,len(lst):  tmp=lst[i]  j=iwhile(j>0 and lst[j-1]>tmp):  lst[j]=lst[j-1] j=j-1lst[j]=tmpreturn lst
lst = input().split(',')
print(insert_sort(lst))


  相关解决方案