선택 정렬
-
[Sort] Selection Sort (선택 정렬)Basic Programming/Algorithm 2018. 12. 11. 18:20
Selection Sort (선택 정렬) - Python - def selection_sort(collection): print('----- Selection Sort -----') print('input : ' + str(collection)) for i in range(len(collection)-1, 0, -1): pos_max = 0 for j in range (1, i+1): if collection[pos_max] < collection[j]: pos_max = j if(pos_max is not i): #if position is same, swap is unnecessary collection[pos_max], collection[i] = collection[i], collection[po..