Although the two algorithms operate in very different ways, it turns out that they are similar in efficiency.
Comparisons | Exchanges | |
---|---|---|
best case | N2 | N-1 |
average case | N2 | N-1 |
worst case | N2 | N-1 |
Comparisons | Exchanges | |
---|---|---|
best case | N-1 | 0 |
average case | N2 | N2/2 |
worst case | N2 | N2/2 |
Both are O (N2)
The best sorting algorithms are O (N . log N)