Which sorting algorithm could have this shape for number of comparisons for n=5:
a)
****
***
**
*
b)
****
c)
*
**
*
***
What is the value of each expression:
27 % 5 = __
10 % 12 = __
12 % 10 = __
375 % 375 = __
What is the value of n after each line is executed:
int n = 5; // n = __
n *= 3; // n = __
n--; // n = __
--n; // n = __
n -= 2; // n = __
n /= 4; // n = __
Consider the following mystery method:
int mystery( int u, int v )
{
int c = 0;
for ( int d = u ; d <= v; d = d + 1 )
{
int e = 0;
for ( int f = d ; f <= v; f = f + 1 )
{
e = e + f;
}
c = c + e;
}
return c;
}
What is computed/returned and stored in answer after executing:
int answer = mystery( 1, 2 );
Consider the following mystery method:
void mystery( int[] u, int v )
{
while ( v < u.length - 2 )
{
u[v+1] = u[v-1];
++v;
if ( u[v] > u[0] )
{
++u[v+1];
}
else
{
u[v] -= u[v+1];
}
}
printArray( u );
}
What is printed after executing:
int[] numbers = { 1, 2, 3, 4, 5, 6 };
mystery( numbers, 1 );