본문 바로가기
스터디/자료구조

[ 자료구조 ] Selection Sort

by 알 수 없는 사용자 2020. 2. 23.

선택 정렬 : 가장 작은 값을 맨 앞으로 보내는 과정을 반복하는 정렬입니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
int main()
{
    int array[10= { 19410625378 };
    int min, index, temp;
 
    for(int i = 0; i < 10++i)
    {
        min = array[i];
        index = i;
 
        for (int j = i; j < 10; j++)
        {
            if (min > array[j])
            {
                min = array[j];
                index = j;
            }
        }
 
        temp = array[i];
        array[i] = array[index];
        array[index] = temp;
 
    }
 
    return 0;
}
 

'스터디 > 자료구조' 카테고리의 다른 글

[ 자료구조 ] Insertion sort  (0) 2020.02.23
[ 자료구조 ] Bubble Sort  (0) 2020.02.23
[ 자료구조 ] Binary Search Tree  (0) 2020.02.23
[ 자료구조 ] Deque  (0) 2020.02.22
[ 자료구조 ] Queue  (0) 2020.02.21