Bubble Sort 작동방식 (간단)
_Bubble Sort 거품 정렬 또는 버블 정렬은 두 인접한 원소를 검사하여 정렬하는 방법이다. 시간 복잡도가 O(n^{2})로 상당히 느리지만, 코드가 단순하기 때문에 자주 사용된다. 원소의 이동이 거품이 수면으로 올라오는 듯한 모습을 보이기 때문에 지어진 이름이다 버블 솔트는 말 그대로 버블이라는 원 하나를 만들어 두개의 원소를 조사하여 더 작은 값을 큰 값이랑 스위치해 왼쪽으로 가게 만들어준다. Bubble Sort는 stable하다 (@@색은 버블이라 생각하면된다) [9, 3, 5, 7, 1] [9, 3, 5, 7, 1] --> [3, 9, 5, 7, 1] [3, 9, 5, 7, 1] --> [3, 5, 9, 7, 1] [3, 5, 9, 7, 1] --> [3, 5, 7, 9, 1] [3, 5,..
2022. 7. 13.