I. 버블 정렬 (Bubble Sort)의 개요
가. 버블 정렬의 정의
여러 개의 자료 중에서 서로 이웃하는 키 값을 두 개씩 비교하여 순서를 결정하는 정렬 방법
나. 버블 정렬의 특징
- 간단하지만 느린 속도의 알고리즘
- flag를 통해 속도 개선 가능
- 수행시간 복잡도: O(n2)
Ⅱ. 버블 정렬의 단계 및 사례
가. 버블 정렬의 단계
![]() |
나. 버블 정렬의 사례
![]() |
/* list에 대한 기본 버블정렬 알고리즘 */ void bubble_sort(element list[], int n) { int i, j; element next; for(i = n-1; i > 0; i--){ for(j = 0; j < i; j++){ if(list[j] > list[j + 1]{ swap(list[j], list[j + 1]); }}}} |
'IT 용어 및 개념 > Algorithm' 카테고리의 다른 글
[Algorithm] 기수 정렬 (Radix Sort) (0) | 2024.09.14 |
---|---|
[Algorithm] 퀵 정렬 (Quick Sort) (0) | 2024.09.14 |
[Algorithm] 해시 탐색 (Hash Search) (0) | 2024.09.14 |
[Algorithm] 합병 정렬 (Merge Sort) (0) | 2024.09.14 |
[Algorithm] 이진 탐색 (Binary Search) (0) | 2024.09.14 |