public static void bubbleSort(int [] A) {
int i,j,swapper;
//invariant: all items in A that are in
an index less than i are
// (1) sorted, and (2) less than any item
in an index >= i}
i = 0;
swapper = 1;
while ((i < A.length) && (swapper != 0)) {
count+=2;
swapper = 0;
j = A.length -1;
while (j > i) {
count++; cmprs++;
if (A[j] < A[j-1]) {
swap(A, j, j-1);
swapper++;
}
j--;
count++;
}
i++;
count++;
}
count++;
} //end bubbleSort