Computer Science II Final Exam
Questions and Answers 2025-2026
Latest Edition.
A ________ function is one that calls itself
A) dynamic
B) static
C) recursive
D) data validation
E) None of these - ANS -C) recursive
Recursion can be used to:
A) compute factorials
B) find GCD's
C) traverse linked lists
D) All of these
E) None of these - ANS -D) All of these
The ________ algorithm uses recursion to efficiently sort a list.
A) shell sort
B) quicksort
C) binary sort
D) red/black sort
E) None of these - ANS -B) quicksort
,If a recursive function does not contain a base case, it ________.
A) returns 0 and stops
B) returns false and stops
C) uses up all available stack memory, causing the program to crash
D) reaches the recursive case and stops
E) None of these - ANS -C) uses up all available stack memory, causing the program to crash
The ________ of recursion is the number of times a recursive function calls itself.
A) level
B) breadth
C) type
D) depth
E) None of these - ANS -D) depth
The programmer must ensure that a recursive function does not become:
A) a static function
B) a virtual function
C) an endless loop
D) a dynamic function
E) None of these - ANS -C) an endless loop
How many times will the following function call itself, if the value 5 is passed as the argument?
void showMessage(int n)
{
if (n > 0)
,{
cout << "Good day!" << endl;
showMessage(n + 1);
}
}
A) 1
B) 4
C) 5
D) An infinite number of times - ANS -D) An infinite number of times
How many times will the following function call itself, if the value 5 is passed as the argument?
void showMessage(int n)
{
if (n > 0)
{
cout << "Good day!" << endl;
showMessage(n - 1);
}
}
A) 1
B) 4
C) 5
D) An infinite number of times - ANS -C) 5
, The QuickSort algorithm works on the basis of
A) three sublists
B) two sublists and a pivot
C) two pivots and a sublist
D) three pivots
E) None of these - ANS -B) two sublists and a pivot
A recursive function is designed to terminate when it reaches its ________.
A) return statement
B) base case
C) closing curly brace
D) last parameter
E) None of these - ANS -B) base case
When function A calls function B, which in turn calls function A, this is known as:
A) direct recursion
B) indirect recursion
C) function swapping
D) perfect recursion
E) None of these - ANS -B) indirect recursion
The QuickSort algorithm is used to sort ________.
A) lists stored in arrays or linear linked lists
B) tree data structures
C) randomly-ordered files
Questions and Answers 2025-2026
Latest Edition.
A ________ function is one that calls itself
A) dynamic
B) static
C) recursive
D) data validation
E) None of these - ANS -C) recursive
Recursion can be used to:
A) compute factorials
B) find GCD's
C) traverse linked lists
D) All of these
E) None of these - ANS -D) All of these
The ________ algorithm uses recursion to efficiently sort a list.
A) shell sort
B) quicksort
C) binary sort
D) red/black sort
E) None of these - ANS -B) quicksort
,If a recursive function does not contain a base case, it ________.
A) returns 0 and stops
B) returns false and stops
C) uses up all available stack memory, causing the program to crash
D) reaches the recursive case and stops
E) None of these - ANS -C) uses up all available stack memory, causing the program to crash
The ________ of recursion is the number of times a recursive function calls itself.
A) level
B) breadth
C) type
D) depth
E) None of these - ANS -D) depth
The programmer must ensure that a recursive function does not become:
A) a static function
B) a virtual function
C) an endless loop
D) a dynamic function
E) None of these - ANS -C) an endless loop
How many times will the following function call itself, if the value 5 is passed as the argument?
void showMessage(int n)
{
if (n > 0)
,{
cout << "Good day!" << endl;
showMessage(n + 1);
}
}
A) 1
B) 4
C) 5
D) An infinite number of times - ANS -D) An infinite number of times
How many times will the following function call itself, if the value 5 is passed as the argument?
void showMessage(int n)
{
if (n > 0)
{
cout << "Good day!" << endl;
showMessage(n - 1);
}
}
A) 1
B) 4
C) 5
D) An infinite number of times - ANS -C) 5
, The QuickSort algorithm works on the basis of
A) three sublists
B) two sublists and a pivot
C) two pivots and a sublist
D) three pivots
E) None of these - ANS -B) two sublists and a pivot
A recursive function is designed to terminate when it reaches its ________.
A) return statement
B) base case
C) closing curly brace
D) last parameter
E) None of these - ANS -B) base case
When function A calls function B, which in turn calls function A, this is known as:
A) direct recursion
B) indirect recursion
C) function swapping
D) perfect recursion
E) None of these - ANS -B) indirect recursion
The QuickSort algorithm is used to sort ________.
A) lists stored in arrays or linear linked lists
B) tree data structures
C) randomly-ordered files