Pancake Sort vs Selection Sort
Same 110 values, same shuffle, same speed. Selection Sort finishes first and turns gold: 6,097 operations to 10,557.
The numbers
- Pancake operations
- 10,557
- Selection operations
- 6,097
- Pancake average
- n²
- Selection average
- n²
- Pancake worst
- n²
- Selection worst
- n²
Pancake Sort
Pancake Sort only reverses prefixes of the list: flip the largest value to the top, then flip it into place. More on Pancake Sort.
Selection Sort
Selection Sort finds the smallest remaining value and swaps it to the front, again and again. More on Selection Sort.
FAQ
Which is faster, Pancake Sort or Selection Sort?
On this shuffle of 110 values, Selection Sort needed 6,097 operations and Pancake Sort needed 10,557, about 1.7× as many. On average Pancake Sort is n² and Selection Sort is n².
Which one is stable?
Neither is stable.
How is the race fair?
Both algorithms start from the same shuffle and run the same number of operations per frame. Every comparison, swap and write counts as one operation, so the one that needs fewer operations finishes first.