|
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
With
the first pass,
|
|
|
|
– |
we
make 1 comparison.
|
|
|
|
– |
With
the second pass, in the worst case we must make 2
|
|
comparisons.
|
|
|
|
– |
With
the third pass, in the worst case we must make 3
|
|
|
comparisons.
|
|
|
|
– |
With
the N-1 pass, in the worst case we must make N-1
|
|
|
comparisons.
|
|
|
|
– |
In
worst case: 1 + 2 + 3 + ... + (N-1)
|
|
|
|
– |
which is: N*(N-1)/2 O(N2)
|
|
|
|
|
|