삽입 정렬
-
[Sort] Insertion Sort (삽입 정렬)Basic Programming/Algorithm 2018. 12. 10. 18:49
Insertion Sort (삽입 정렬) - Python - def insertion_sort(collection): print('----- Insertion Sort -----') print('input : ' + str(collection)) for i in range(1, len(collection)): while 0 < i and collection[i] < collection[i-1]: collection[i], collection[i-1] = collection[i-1], collection[i] i = i - 1 print('progressing ... ' + str(collection)) return collection input = [3, 1, 6, 8, 4, 2, 9, 7, 10, 5]..