•During the first
pass, there are N-1 comparisons and
at most N-1 exchanges.
•During the second pass, there are N-2 comparisons and at most N-2 exchanges.
•Therefore, in the worst case there are comparisons of:
• (N-1)+(N-2)+...+ 1 = N*(N-1)/2
•and, the same number of exchanges... N*(N-1)/2*4 which
is: 2N*N - 2*N