Part 1- Recursion, Algorithm
Analysis & Stack Questions
with Answers
Data structures can be said to be an ADT's ______.
1 specifications
2 implementation
3 abstraction
4 definition - Correct Answers: 2 implementation
The specifications of an ADT's operations indicate ______.
1 what the operations do
2 how to store the data in the ADT
3 how to carry out the operations
4 how to implement the operations - Correct Answers: 2 what the operations do
Which of the following is not an primitive data type in C++?
1 string
2 char
3 bool
4 double - Correct Answers: 1 string
In a recursive solution to a problem, we solve a problem P(n) by solving another problem P(k) where
1 P(k) is smaller than P(n)
2 P(k) is same as P(n)
3 P(k) is the hardest part of P(n)
4 P(k) is a larger problem than P(n) - Correct Answers: 1 P(k) is smaller than P(n)
, A(n) ______ is a C++ construct that enables a programmer to define a new data type.
1 data field
2 object
3 method
4 class - Correct Answers: 4 class
The function
int fact (int k)
{
return k * fact(k-1);
if (k == 0) return 1;
}
1 computes the factorial on an integer k passed to it as parameter
2 works for all non-negative values of k, but not for negative numbers.
3 returns the value 1 if it is passed a value of 0 for the parameter k
4 does not correctly handle its base case - Correct Answers: 4 does not correctly handle its base case
When a function contains a function call to itself, such function is _____.
1 self-reference
2 reciprocal
3 repetitive
4 recursive - Correct Answers: 4 recursive
The factorial of n is equal to
1 factorial (n-1)
2 n - factorial (n-1)
3 n * factorial (n-1)
4 n - 1 - Correct Answers: 3 n * factorial (n-1)