Python 선택정렬 구현

1 개요[ | ]

Python 선택정렬 구현
파이썬 선택정렬 구현
def selection_sort(a):
    size = len(a)
    for i in range(size):
        minidx = i
        for j in range(i+1,size):
            if(a[minidx]>a[j]): minidx=j
        a[minidx], a[i] = a[i], a[minidx]
arr = [9,1,22,4,0,-1,1,22,100,10]
selection_sort( arr )
print( arr )
# [-1, 0, 1, 1, 4, 9, 10, 22, 22, 100]

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}