SlideShare a Scribd company logo
Algorithm
Selection Sort
Bill Kim(김정훈) | ibillkim@gmail.com
목차
•Selection Sort
•Concept
•Features
•Implementation
•References
Selection Sort
Selection Sort(선택 정렬)은 배열의 전체 원소들을 중에서 기준
위치에 맞는 원소를 선택하여 자리를 교환하는 방식으로 정렬하는
정렬 알고리즘입니다.
즉 전체 원소 중에서 가장 작은 원소를 찾아서 선택하고 기준 원소
와 자리를 교환하는 방식입니다.
Concept
기본적인 알고리즘의 컨셉을 살펴보면 아래와 같습니다.
1. 배열 요소 중에서 가장 작은 값을 찾습니다.
2. 제일 작은 값을 첫 번째 요소와 자리를 교체합니다.
3. 이번에는 2번째부터 전체 배열 요소 중 가장 작은 값을 다시 찾
습니다.
4. 다시 2번과 같이 2번째 자리의 요소와 가장 작은 값을 비교 후
자리를 교체합니다.
5. 배열의 마지막 자리까지 위와 같은 방법을 반복합니다.
Concept
[ 8, 3, 5, 4, 6 ] 인 배열을 정렬한다고 생각해봅니다.
위에서 설명한 방식대로 진행하면 아래와 같은 흐름으로 진행됨을
알 수 있습니다.
8 3 5 4 6 3 8 5 4 6
3 8 5 4 63 4 5 8 6
Concept
3 4 5 8 6 3 4 5 8 6
3 4 5 8 63 4 5 6 8
3 4 5 6 8
Features
선택 정렬은 아래와 같은 특징을 가진 알고리즘입니다.
1. 배열 요소 중에서 가장 작은 값을 찾고 해당 값을 제일 앞으로 이
동시켜 교환하면서 비교하는 정렬 알고리즘
2. 이중 루프로서 구현이 됨에 따라서 최고, 최악, 평균 모두 시간 복
잡도가 O(n^2)이다.
3. 버블 정렬과 비슷하게 요소를 비교하지만 교환은 단 한번만 이루
어진다.
Implementation
Swift를 활용하여 선택 정렬 알고리즘을 살펴보겠습니다.
func selectionSort<T : Comparable>(_ array: [T]) -> [T] {
var arr = array
for stand in 0 ..< (arr.count - 1) {
var lowest = stand
for index in (stand + 1) ..< arr.count {
if arr[lowest] > arr[index] {
lowest = index
}
let tmp = arr[lowest]
arr[lowest] = arr[stand]
arr[stand] = tmp
}
}
return arr
}
Implementation
let numbers = [ 5, -2, 3, 1, 10, 9, 6, 8, 7, 0 ]
print(selectionSort(numbers)) // [-2, 0, 1, 3, 5, 6, 7, 8, 9, 10]
References
[1] Swift3 ) Swift로 선택정렬(Selection Sort)짜보기 :
https://zeddios.tistory.com/66
[2] 선택 정렬 selection sort with swift : https://
hyerios.tistory.com/66
[3] 버블 정렬과 선택 정렬 : https://
usinuniverse.bitbucket.io/blog/sort-algorithm-1.html
[4] Swift Language 선택 정렬 : https://riptutorial.com/
ko/swift/example/28305/선택-정렬
[5] [Sort] 선택 정렬(Selection Sort) : https://
palpit.tistory.com/123
References
[6] Sorting Algorithms: Implementing Selection Sort Using
Swift : https://medium.com/appcoda-tutorials/sorting-
algorithms-implementing-selection-sort-using-
swift-30500ae6b93a
[7] [Algorithm] Selection Sort, 선택 정렬 : https://velog.io/
@delmasong/Algorithm-Selection-Sort-선택-정렬
[8] What is Selection Sort? : https://www.codingame.com/
playgrounds/506/sorting-in-swift/selection-sort
[9] [알고리즘] 정렬 알고리즘 - 선택,버블,삽입 : https://baked-
corn.tistory.com/114
[10] 선택 정렬 : https://ko.wikipedia.org/wiki/선택_정렬
Thank you!

More Related Content

What's hot

Haskell study 13
Haskell study 13Haskell study 13
Haskell study 13
Nam Hyeonuk
 
[Swift] Data Structure - Array
[Swift] Data Structure - Array[Swift] Data Structure - Array
[Swift] Data Structure - Array
Bill Kim
 
Haskell study 12
Haskell study 12Haskell study 12
Haskell study 12
Nam Hyeonuk
 
제4장 sql 함수를 사용해보기
제4장 sql 함수를 사용해보기제4장 sql 함수를 사용해보기
제4장 sql 함수를 사용해보기
sang doc Lee
 
Haskell study 7
Haskell study 7Haskell study 7
Haskell study 7
Nam Hyeonuk
 
[Algorithm] Binary Search
[Algorithm] Binary Search[Algorithm] Binary Search
[Algorithm] Binary Search
Bill Kim
 
Haskell study 4
Haskell study 4Haskell study 4
Haskell study 4
Nam Hyeonuk
 
Haskell study 6
Haskell study 6Haskell study 6
Haskell study 6
Nam Hyeonuk
 
Haskell study 14
Haskell study 14Haskell study 14
Haskell study 14
Nam Hyeonuk
 
Haskell study 10
Haskell study 10Haskell study 10
Haskell study 10
Nam Hyeonuk
 
Haskell study 2
Haskell study 2Haskell study 2
Haskell study 2
Nam Hyeonuk
 
[Commit Again] 1주차 STL study
[Commit Again] 1주차 STL study[Commit Again] 1주차 STL study
[Commit Again] 1주차 STL study
경 송
 
[Swift] Data Structure - Heap
[Swift] Data Structure - Heap[Swift] Data Structure - Heap
[Swift] Data Structure - Heap
Bill Kim
 
R 프로그래밍 기본 문법
R 프로그래밍 기본 문법R 프로그래밍 기본 문법
R 프로그래밍 기본 문법
Terry Cho
 
Haskell study 9
Haskell study 9Haskell study 9
Haskell study 9
Nam Hyeonuk
 
알고리즘 스터디(정렬) Seungdols
알고리즘 스터디(정렬) Seungdols알고리즘 스터디(정렬) Seungdols
알고리즘 스터디(정렬) Seungdols
seungdols
 
Haskell study 15
Haskell study 15Haskell study 15
Haskell study 15
Nam Hyeonuk
 
Data Structures
Data StructuresData Structures
Data Structures
skku_npc
 
알고리즘과 자료구조
알고리즘과 자료구조알고리즘과 자료구조
알고리즘과 자료구조
영기 김
 

What's hot (20)

Haskell study 13
Haskell study 13Haskell study 13
Haskell study 13
 
[Swift] Data Structure - Array
[Swift] Data Structure - Array[Swift] Data Structure - Array
[Swift] Data Structure - Array
 
Haskell study 12
Haskell study 12Haskell study 12
Haskell study 12
 
제4장 sql 함수를 사용해보기
제4장 sql 함수를 사용해보기제4장 sql 함수를 사용해보기
제4장 sql 함수를 사용해보기
 
Haskell study 7
Haskell study 7Haskell study 7
Haskell study 7
 
[Algorithm] Binary Search
[Algorithm] Binary Search[Algorithm] Binary Search
[Algorithm] Binary Search
 
Haskell study 4
Haskell study 4Haskell study 4
Haskell study 4
 
Haskell study 6
Haskell study 6Haskell study 6
Haskell study 6
 
Apply교육
Apply교육Apply교육
Apply교육
 
Haskell study 14
Haskell study 14Haskell study 14
Haskell study 14
 
Haskell study 10
Haskell study 10Haskell study 10
Haskell study 10
 
Haskell study 2
Haskell study 2Haskell study 2
Haskell study 2
 
[Commit Again] 1주차 STL study
[Commit Again] 1주차 STL study[Commit Again] 1주차 STL study
[Commit Again] 1주차 STL study
 
[Swift] Data Structure - Heap
[Swift] Data Structure - Heap[Swift] Data Structure - Heap
[Swift] Data Structure - Heap
 
R 프로그래밍 기본 문법
R 프로그래밍 기본 문법R 프로그래밍 기본 문법
R 프로그래밍 기본 문법
 
Haskell study 9
Haskell study 9Haskell study 9
Haskell study 9
 
알고리즘 스터디(정렬) Seungdols
알고리즘 스터디(정렬) Seungdols알고리즘 스터디(정렬) Seungdols
알고리즘 스터디(정렬) Seungdols
 
Haskell study 15
Haskell study 15Haskell study 15
Haskell study 15
 
Data Structures
Data StructuresData Structures
Data Structures
 
알고리즘과 자료구조
알고리즘과 자료구조알고리즘과 자료구조
알고리즘과 자료구조
 

Similar to [Algorithm] Selection Sort

[데브루키]노대영_알고리즘 스터디
[데브루키]노대영_알고리즘 스터디[데브루키]노대영_알고리즘 스터디
[데브루키]노대영_알고리즘 스터디
대영 노
 
알고리즘
알고리즘알고리즘
알고리즘
승우 백
 
Quick sort
Quick sortQuick sort
Quick sort
HyungjunJu
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율
[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율
[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율
S.O.P.T - Shout Our Passion Together
 
[Algorithm] Sorting Comparison
[Algorithm] Sorting Comparison[Algorithm] Sorting Comparison
[Algorithm] Sorting Comparison
Bill Kim
 
Python_numpy_pandas_matplotlib 이해하기_20160815
Python_numpy_pandas_matplotlib 이해하기_20160815Python_numpy_pandas_matplotlib 이해하기_20160815
Python_numpy_pandas_matplotlib 이해하기_20160815
Yong Joon Moon
 
[Algorithm] Shell Sort
[Algorithm] Shell Sort[Algorithm] Shell Sort
[Algorithm] Shell Sort
Bill Kim
 
개경프 1주차 Stl study
개경프 1주차 Stl study개경프 1주차 Stl study
개경프 1주차 Stl study
경 송
 
2012 Dm A0 03 Pdf
2012 Dm A0 03 Pdf2012 Dm A0 03 Pdf
2012 Dm A0 03 Pdfkd19h
 
2012 Dm A0 03 Pdf
2012 Dm A0 03 Pdf2012 Dm A0 03 Pdf
2012 Dm A0 03 Pdfjinwookhong
 
퀵 정렬 알고리즘 기초
퀵 정렬 알고리즘 기초퀵 정렬 알고리즘 기초
퀵 정렬 알고리즘 기초
Dongyi Kim
 
Erlang을 이용한 swap 서버
Erlang을 이용한 swap 서버Erlang을 이용한 swap 서버
Erlang을 이용한 swap 서버Jaejin Yun
 
Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체
Circulus
 
람다, 스트림 Api
람다, 스트림 Api람다, 스트림 Api
람다, 스트림 Api
Chi Hwan Choi
 
Linq to object using c#
Linq to object using c#Linq to object using c#
Linq to object using c#병걸 윤
 
Computational Complexity
Computational ComplexityComputational Complexity
Computational Complexity
skku_npc
 
파이썬 문자열 이해하기
파이썬 문자열 이해하기파이썬 문자열 이해하기
파이썬 문자열 이해하기
Yong Joon Moon
 

Similar to [Algorithm] Selection Sort (20)

sort algorithim
sort algorithimsort algorithim
sort algorithim
 
[데브루키]노대영_알고리즘 스터디
[데브루키]노대영_알고리즘 스터디[데브루키]노대영_알고리즘 스터디
[데브루키]노대영_알고리즘 스터디
 
알고리즘
알고리즘알고리즘
알고리즘
 
Quick sort
Quick sortQuick sort
Quick sort
 
[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율
[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율
[SOPT] 데이터 구조 및 알고리즘 스터디 - #03 : 정렬 (기본, 효율, 초효율
 
[Algorithm] Sorting Comparison
[Algorithm] Sorting Comparison[Algorithm] Sorting Comparison
[Algorithm] Sorting Comparison
 
Python_numpy_pandas_matplotlib 이해하기_20160815
Python_numpy_pandas_matplotlib 이해하기_20160815Python_numpy_pandas_matplotlib 이해하기_20160815
Python_numpy_pandas_matplotlib 이해하기_20160815
 
[Algorithm] Shell Sort
[Algorithm] Shell Sort[Algorithm] Shell Sort
[Algorithm] Shell Sort
 
개경프 1주차 Stl study
개경프 1주차 Stl study개경프 1주차 Stl study
개경프 1주차 Stl study
 
2012 Dm A0 03 Pdf
2012 Dm A0 03 Pdf2012 Dm A0 03 Pdf
2012 Dm A0 03 Pdf
 
2012 Dm A0 03 Pdf
2012 Dm A0 03 Pdf2012 Dm A0 03 Pdf
2012 Dm A0 03 Pdf
 
퀵 정렬 알고리즘 기초
퀵 정렬 알고리즘 기초퀵 정렬 알고리즘 기초
퀵 정렬 알고리즘 기초
 
Erlang을 이용한 swap 서버
Erlang을 이용한 swap 서버Erlang을 이용한 swap 서버
Erlang을 이용한 swap 서버
 
Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체Startup JavaScript 4 - 객체
Startup JavaScript 4 - 객체
 
람다, 스트림 Api
람다, 스트림 Api람다, 스트림 Api
람다, 스트림 Api
 
Linq to object using c#
Linq to object using c#Linq to object using c#
Linq to object using c#
 
Computational Complexity
Computational ComplexityComputational Complexity
Computational Complexity
 
3주차 스터디
3주차 스터디3주차 스터디
3주차 스터디
 
2012 Ds 01
2012 Ds 012012 Ds 01
2012 Ds 01
 
파이썬 문자열 이해하기
파이썬 문자열 이해하기파이썬 문자열 이해하기
파이썬 문자열 이해하기
 

More from Bill Kim

[Algorithm] Big O Notation
[Algorithm] Big O Notation[Algorithm] Big O Notation
[Algorithm] Big O Notation
Bill Kim
 
[Algorithm] Radix Sort
[Algorithm] Radix Sort[Algorithm] Radix Sort
[Algorithm] Radix Sort
Bill Kim
 
[Algorithm] Heap Sort
[Algorithm] Heap Sort[Algorithm] Heap Sort
[Algorithm] Heap Sort
Bill Kim
 
[Algorithm] Merge Sort
[Algorithm] Merge Sort[Algorithm] Merge Sort
[Algorithm] Merge Sort
Bill Kim
 
[Algorithm] Recursive(재귀)
[Algorithm] Recursive(재귀)[Algorithm] Recursive(재귀)
[Algorithm] Recursive(재귀)
Bill Kim
 
[Swift] Data Structure - AVL
[Swift] Data Structure - AVL[Swift] Data Structure - AVL
[Swift] Data Structure - AVL
Bill Kim
 
[Swift] Data Structure - Binary Search Tree
[Swift] Data Structure - Binary Search Tree[Swift] Data Structure - Binary Search Tree
[Swift] Data Structure - Binary Search Tree
Bill Kim
 
[Swift] Data Structure - Graph(BFS)
[Swift] Data Structure - Graph(BFS)[Swift] Data Structure - Graph(BFS)
[Swift] Data Structure - Graph(BFS)
Bill Kim
 
[Swift] Data Structure - Graph(DFS)
[Swift] Data Structure - Graph(DFS)[Swift] Data Structure - Graph(DFS)
[Swift] Data Structure - Graph(DFS)
Bill Kim
 
[Swift] Data Structure - Binary Tree
[Swift] Data Structure - Binary Tree[Swift] Data Structure - Binary Tree
[Swift] Data Structure - Binary Tree
Bill Kim
 
[Swift] Data Structure - Tree
[Swift] Data Structure - Tree[Swift] Data Structure - Tree
[Swift] Data Structure - Tree
Bill Kim
 
[Swift] Data Structure - Graph
[Swift] Data Structure - Graph[Swift] Data Structure - Graph
[Swift] Data Structure - Graph
Bill Kim
 
[Swift] Data Structure - Dequeue
[Swift] Data Structure - Dequeue[Swift] Data Structure - Dequeue
[Swift] Data Structure - Dequeue
Bill Kim
 
[Swift] Data Structure - Stack
[Swift] Data Structure - Stack[Swift] Data Structure - Stack
[Swift] Data Structure - Stack
Bill Kim
 
[Swift] Data Structure - Queue
[Swift] Data Structure - Queue[Swift] Data Structure - Queue
[Swift] Data Structure - Queue
Bill Kim
 
[Swift] Data Structure - Linked List
[Swift] Data Structure - Linked List[Swift] Data Structure - Linked List
[Swift] Data Structure - Linked List
Bill Kim
 
[Swift] Data Structure Introduction
[Swift] Data Structure Introduction[Swift] Data Structure Introduction
[Swift] Data Structure Introduction
Bill Kim
 
Design Pattern Introduction
Design Pattern IntroductionDesign Pattern Introduction
Design Pattern Introduction
Bill Kim
 
[Swift] Visitor
[Swift] Visitor[Swift] Visitor
[Swift] Visitor
Bill Kim
 
[Swift] Template Method
[Swift] Template Method[Swift] Template Method
[Swift] Template Method
Bill Kim
 

More from Bill Kim (20)

[Algorithm] Big O Notation
[Algorithm] Big O Notation[Algorithm] Big O Notation
[Algorithm] Big O Notation
 
[Algorithm] Radix Sort
[Algorithm] Radix Sort[Algorithm] Radix Sort
[Algorithm] Radix Sort
 
[Algorithm] Heap Sort
[Algorithm] Heap Sort[Algorithm] Heap Sort
[Algorithm] Heap Sort
 
[Algorithm] Merge Sort
[Algorithm] Merge Sort[Algorithm] Merge Sort
[Algorithm] Merge Sort
 
[Algorithm] Recursive(재귀)
[Algorithm] Recursive(재귀)[Algorithm] Recursive(재귀)
[Algorithm] Recursive(재귀)
 
[Swift] Data Structure - AVL
[Swift] Data Structure - AVL[Swift] Data Structure - AVL
[Swift] Data Structure - AVL
 
[Swift] Data Structure - Binary Search Tree
[Swift] Data Structure - Binary Search Tree[Swift] Data Structure - Binary Search Tree
[Swift] Data Structure - Binary Search Tree
 
[Swift] Data Structure - Graph(BFS)
[Swift] Data Structure - Graph(BFS)[Swift] Data Structure - Graph(BFS)
[Swift] Data Structure - Graph(BFS)
 
[Swift] Data Structure - Graph(DFS)
[Swift] Data Structure - Graph(DFS)[Swift] Data Structure - Graph(DFS)
[Swift] Data Structure - Graph(DFS)
 
[Swift] Data Structure - Binary Tree
[Swift] Data Structure - Binary Tree[Swift] Data Structure - Binary Tree
[Swift] Data Structure - Binary Tree
 
[Swift] Data Structure - Tree
[Swift] Data Structure - Tree[Swift] Data Structure - Tree
[Swift] Data Structure - Tree
 
[Swift] Data Structure - Graph
[Swift] Data Structure - Graph[Swift] Data Structure - Graph
[Swift] Data Structure - Graph
 
[Swift] Data Structure - Dequeue
[Swift] Data Structure - Dequeue[Swift] Data Structure - Dequeue
[Swift] Data Structure - Dequeue
 
[Swift] Data Structure - Stack
[Swift] Data Structure - Stack[Swift] Data Structure - Stack
[Swift] Data Structure - Stack
 
[Swift] Data Structure - Queue
[Swift] Data Structure - Queue[Swift] Data Structure - Queue
[Swift] Data Structure - Queue
 
[Swift] Data Structure - Linked List
[Swift] Data Structure - Linked List[Swift] Data Structure - Linked List
[Swift] Data Structure - Linked List
 
[Swift] Data Structure Introduction
[Swift] Data Structure Introduction[Swift] Data Structure Introduction
[Swift] Data Structure Introduction
 
Design Pattern Introduction
Design Pattern IntroductionDesign Pattern Introduction
Design Pattern Introduction
 
[Swift] Visitor
[Swift] Visitor[Swift] Visitor
[Swift] Visitor
 
[Swift] Template Method
[Swift] Template Method[Swift] Template Method
[Swift] Template Method
 

[Algorithm] Selection Sort

  • 3. Selection Sort Selection Sort(선택 정렬)은 배열의 전체 원소들을 중에서 기준 위치에 맞는 원소를 선택하여 자리를 교환하는 방식으로 정렬하는 정렬 알고리즘입니다. 즉 전체 원소 중에서 가장 작은 원소를 찾아서 선택하고 기준 원소 와 자리를 교환하는 방식입니다.
  • 4. Concept 기본적인 알고리즘의 컨셉을 살펴보면 아래와 같습니다. 1. 배열 요소 중에서 가장 작은 값을 찾습니다. 2. 제일 작은 값을 첫 번째 요소와 자리를 교체합니다. 3. 이번에는 2번째부터 전체 배열 요소 중 가장 작은 값을 다시 찾 습니다. 4. 다시 2번과 같이 2번째 자리의 요소와 가장 작은 값을 비교 후 자리를 교체합니다. 5. 배열의 마지막 자리까지 위와 같은 방법을 반복합니다.
  • 5. Concept [ 8, 3, 5, 4, 6 ] 인 배열을 정렬한다고 생각해봅니다. 위에서 설명한 방식대로 진행하면 아래와 같은 흐름으로 진행됨을 알 수 있습니다. 8 3 5 4 6 3 8 5 4 6 3 8 5 4 63 4 5 8 6
  • 6. Concept 3 4 5 8 6 3 4 5 8 6 3 4 5 8 63 4 5 6 8 3 4 5 6 8
  • 7. Features 선택 정렬은 아래와 같은 특징을 가진 알고리즘입니다. 1. 배열 요소 중에서 가장 작은 값을 찾고 해당 값을 제일 앞으로 이 동시켜 교환하면서 비교하는 정렬 알고리즘 2. 이중 루프로서 구현이 됨에 따라서 최고, 최악, 평균 모두 시간 복 잡도가 O(n^2)이다. 3. 버블 정렬과 비슷하게 요소를 비교하지만 교환은 단 한번만 이루 어진다.
  • 8. Implementation Swift를 활용하여 선택 정렬 알고리즘을 살펴보겠습니다. func selectionSort<T : Comparable>(_ array: [T]) -> [T] { var arr = array for stand in 0 ..< (arr.count - 1) { var lowest = stand for index in (stand + 1) ..< arr.count { if arr[lowest] > arr[index] { lowest = index } let tmp = arr[lowest] arr[lowest] = arr[stand] arr[stand] = tmp } } return arr }
  • 9. Implementation let numbers = [ 5, -2, 3, 1, 10, 9, 6, 8, 7, 0 ] print(selectionSort(numbers)) // [-2, 0, 1, 3, 5, 6, 7, 8, 9, 10]
  • 10. References [1] Swift3 ) Swift로 선택정렬(Selection Sort)짜보기 : https://zeddios.tistory.com/66 [2] 선택 정렬 selection sort with swift : https:// hyerios.tistory.com/66 [3] 버블 정렬과 선택 정렬 : https:// usinuniverse.bitbucket.io/blog/sort-algorithm-1.html [4] Swift Language 선택 정렬 : https://riptutorial.com/ ko/swift/example/28305/선택-정렬 [5] [Sort] 선택 정렬(Selection Sort) : https:// palpit.tistory.com/123
  • 11. References [6] Sorting Algorithms: Implementing Selection Sort Using Swift : https://medium.com/appcoda-tutorials/sorting- algorithms-implementing-selection-sort-using- swift-30500ae6b93a [7] [Algorithm] Selection Sort, 선택 정렬 : https://velog.io/ @delmasong/Algorithm-Selection-Sort-선택-정렬 [8] What is Selection Sort? : https://www.codingame.com/ playgrounds/506/sorting-in-swift/selection-sort [9] [알고리즘] 정렬 알고리즘 - 선택,버블,삽입 : https://baked- corn.tistory.com/114 [10] 선택 정렬 : https://ko.wikipedia.org/wiki/선택_정렬