Data structures
1 of 10
When you have an exact definition of a recursive problem, what is the next step?
Determining the size
Choosing the base case
Choosing the recursive case
None of the above
2 of 10
The data structure that keeps track of activation records during the execution of a program is the
run-time queue
run-time stack
linked list
heap
What happens in the QuickSort algorithm if the items are already sorted?
A compile error occurs.
A run-time error occurs.
QuickSort executes in log time.
QuickSort executes in linear time.
4 of 10
A __________ structure is the main control structure in a recursive routine, and a __________ structure is the main control structure in an iterative routine.
branching, looping
branching, branching
looping, branching
looping, looping
5 of 10
Which of the following statements could describe the general (recursive) case of a recursive algorithm?
F(x) = x – F(x – 1)
F(0) = 27
If the array length is 100, do nothing.
All parameters are integers
6
Numbers 0 through 10 are stored as data in the following singly linked list structure:
Choose the recursive function that will print out the linked list backwards (10 through 0).
7 of 10
In the following recursive function, which line(s) represent the base case?
void PrintIt( /* in */ int n ) // Line 1
{ // Line 2
if (n > 0) // Line 3
{ // Line 4
cout << “Again” << endl; // Line 5
PrintIt(n – 1); // Line 6
} // Line 7
else // Line 8
cout << n << endl; // Line 9
}
lines 5-6
lines 5-9
lines 6-9
line 9
8 of 10
In the following recursive function, which line(s) represent the general (recursive) case?
void PrintIt( /* in */ int n ) // Line 1
{ // Line 2
if (n > 0) // Line 3
{ // Line 4
cout << “Again” << endl; // Line 5
PrintIt(n – 1); // Line 6
} // Line 7
else // Line 8
cout << n << endl; // Line 9
}
lines 5-6
lines 5-9
lines 6-9
line 9
Given the recursive function
int Func( /* in */ int n )
{
if (n == 5)
return 5;
else
return 2 * Func(n + 1);
}
what is the value of the expression Func(2) ?
5
20
40
80
If the following function is called with a value of 73 for n, what is the resulting output?
void Func( /* in */ int n )
{
if (n > 0)
{
Func(n / 5);
cout << n % 5;
}
}
143
243
342
None of the above

+1 862 207 3288 