Now, before anyone says anything, I know that using a goto statement is not "right". Either way, my school professor asked us to modify a piece of code we have previously written and used to work with go to statements. The following is a bubble sort algorithm that we have to modify. Could you guys explain to me where I would insert go to statements to get this algorithm to work with them? A is the name assigned to the array that holds the numbers that are to be sorted.
Code:int i,pass;
boolean swapMade;
pass = 1;
*numberCompares = 0;
*numberMoves = 0;
do
{
swapMade = false;
for (i = 0; i <= n-(pass+1); i++)
{
*numberCompares += 1;
if ( ShouldSwap(A[i],A[i+1]) )
{
int T = A[i]; A[i] = A[i+1]; A[i+1] = T;
*numberMoves += 3;
swapMade = true;
}
}
pass++;
} while ( swapMade );