|
Selection Sort
An Introduction with Examples |
|
Prof. David Bernstein
|
| Computer Science Department |
| bernstdh@jmu.edu |
| 8 | 4 | 7 | 3 | 3 | 9 |
| 3 | 4 | 7 | 3 | 8 | 9 |
| 3 | 4 | 3 | 7 | 8 | 9 |
| 3 | 3 | 4 | 7 | 8 | 9 |
| 3 | 3 | 4 | 7 | 8 | 9 |
\( T(n) = (n-1) + (n-2) + \cdots 2 + 1 = n \cdot (n-1)/2 \)
So: \( T(n) = O(n^2) \)