
CS 공부/기초 알고리즘
[C언어/기초알고리즘] 선택 정렬 (Selection sort)
선택 정렬 알고리즘의 시간 복잡도는 O(N^2)이다. 선택 정렬 알고리즘을 C언어로 작성 한 것이다. #include int main(void){ int i, j, min, index, temp; int array[10] = {1, 10, 5, 8, 7 , 6, 4, 3, 2, 9}; for(i = 0; i array[j]) { min = array[j]; index = j; } } temp = array[i]; array[i] = array[index]; array[index] = temp; } for(i = 0; i