The worst sorting algorithm you'll ever love.
BumbleSort is a deliberately terrible sorting algorithm that picks two random elements, swaps them, and checks if the list happens to be sorted. It's a joke algorithm meant for entertainment, not production use.
- Randomly swaps elements until sorted
- O(n! * n) average time complexity
- Guaranteed to make you appreciate real sorting algorithms
- Benchmark comparisons included
- C++17 compiler
- CMake 3.13+
- GoogleTest (fetched automatically)
mkdir build && cd build
cmake ..
make./build/src/bumble_sort/bumble_sort| n | Time (s) |
|---|---|
| 8 | 0.0003 |
| 10 | 0.40 |
| 12 | 52.75 |
cd build
ctestNote: Unit tests are minimal given the algorithm's simplicity.
MIT License
Rich Nistuk - rnistuk
- Bruce Tognazzini's blog - Where I learned about BumbleSort
- J David Eisenberg - The inventor of BumbleSort