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