자료구조(data structure)
정렬 알고리즘 - 삽입정렬(insertion sort) - 파이썬(python)
진한색
2022. 12. 24. 11:33
삽입정렬 code
def insertion_sort(lists):
global count3
n=len(lists)
for loop in range(1,n):
f,i=loop,loop-1
while i>=0:
if lists[f]<lists[i]:
lists[f],lists[i]=lists[i],lists[f]
count3+=1
f=i
i-=1
else:
break
728x90