반응형
Compute Complexity
Simple Sort
Bubble Sort
- Simple sorting
1. Starts from the end to the begin, compare two values and switch them to put smaller one left.
2. When it reaches the begin. Mark the beginning as done. And do it again till all marks done.
Complexity
- Average: O(n^2)
- Worst: O(n^2)
- Best: 2n
ex) [ 5 3 2 9]
- [ 5 3 2 9 ]
- [ 5 2 3 9 ]
- [ 2 5 3 9 ]
- [ 2 5 3 9 ]
- [ 2 3 5 9 ]
- [ 2 3 5 9 ]
- [ 2 3 5 9 ]
- [ 2 3 5 9 ]
Python Code
Selection Sort
Insertion Sort
Efficient Sort
Heap Sort
Bubble Sort Varients
Distribution Sort
Refer: https://en.wikipedia.org/wiki/Sorting_algorithm#Simple_sorts
반응형
'Etc' 카테고리의 다른 글
유니티 소프트웨어 (Unity): 가격 정책 논란 후 살인 협박에 의한 사무실 폐쇄 (1) | 2023.09.15 |
---|---|
Check current running processes (0) | 2015.02.09 |
pcntl_fork php Lost connection to MySQL (0) | 2015.02.09 |
vi 편집기 (0) | 2015.02.09 |
실리콘 밸리의 창업 (0) | 2014.09.10 |