a[] = {45, 90, 2, 50};
for (int x=0; x < MAX-1; x++)
for (int y=0; y < MAX-x-1; y++)
if (a[y] > a[y+1])
{
t=a[y];
a[y]=a[y+1];
a[y+1]=t;
}
/* print sorted array */
printf("--------------------\n");
for (i=0; i < MAX; i++)
printf("%d\n",a[i]);
i've been trying to go through this code on paper so I have a better understanding bubble sort works but I keep making mistakes in keeping count of the variables and losing my place in the loops.
Is there a model or method to solve this program on paper?