Odd-Even Sort vs Bubble Sort
Same 110 values, same shuffle, same speed. Odd-Even Sort finishes first and turns gold: 8,297 operations to 8,678.
The numbers
- Odd-Even operations
- 8,297
- Bubble operations
- 8,678
- Odd-Even average
- n²
- Bubble average
- n²
- Odd-Even worst
- n²
- Bubble worst
- n²
Odd-Even Sort
Odd-Even Sort alternates between comparing odd-indexed pairs and even-indexed pairs of neighbours. More on Odd-Even Sort.
Bubble Sort
Bubble Sort walks through the list swapping neighbours that are out of order, until a pass makes no swaps. More on Bubble Sort.
FAQ
Which is faster, Odd-Even Sort or Bubble Sort?
On this shuffle of 110 values, Odd-Even Sort needed 8,297 operations and Bubble Sort needed 8,678, about 1.0× as many. On average Odd-Even Sort is n² and Bubble Sort is n².
Which one is stable?
Both are 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.