This bubble sort is kinda freaks me out. I got it two other ways with Number of comparisons = 48 and 81 but this one ....

Anyone can help me please email me at [email protected]

Data item in original order

2 6 4 8 10 12 89 68 45 37

after passing 0 : 2 4 6 8 10 12 68 45 37 89
after passing 1 : 2 4 6 8 10 12 45 37 68
after passing 2 : 2 4 6 8 10 12 37 45
after passing 3 : 2 4 6 8 10 12 37
after passing 4 : 2 4 6 8 10 12
after passing 5 : 2 4 6 8 10
after passing 6 : 2 4 6 8
after passing 7 : 2 4 6
after passing 8 : 2 4



Data items in ascending order
2 4 6 8 10 12 37 45 68 89
Number of comparisons = 24
Press any key to continue



part of my code


for (int i = SIZE-1; i >= 0; i--)
{
for (int j = 1; j <= i; j++)
{
if (a[j-1] > a[j])
{
temp = a[j-1];
a[j-1] = a[j];
a[j] = temp;
}
numberOfComp++;
}