# 참고
Sorting (Bubble, Selection, Insertion, Merge, Quick, Counting, Radix) - VisuAlgo
VisuAlgo is free of charge for Computer Science community on earth. If you like VisuAlgo, the only "payment" that we ask of you is for you to tell the existence of VisuAlgo to other Computer Science students/instructors that you know =) via Facebook/Twitte
visualgo.net
# 코드
def insertion_sort(input):
data = input
size = len(data)
for target in range(1, size):
copy_target = data[target]
for index in range(target-1, -1, -1):
if (copy_target < data[index]):
data[index+1] = data[index]
data[index] = copy_target
else:
break
if __name__ == '__main__':
input = [10,9,8,7,6,5,4,3,2,1,0]
insertion_sort(input)
print(input)
# 시간복잡도
O(n^2)
'•알고리즘(Algorithm ) > 스터디' 카테고리의 다른 글
[알고리즘] 병합정렬(merge-sort) 파이썬 (0) | 2022.07.24 |
---|---|
[알고리즘] 재귀함수 파이썬, 회문검사 (0) | 2022.07.23 |
[알고리즘] 선택 정렬 파이썬 (0) | 2022.07.22 |
[알고리즘] 버블정렬 파이썬 (0) | 2022.07.22 |
[정렬] 버블정렬(Bubble Sort) 알고리즘 (0) | 2021.05.21 |