Exam 15: Recursion
Exam 1: An Overview of Computers and Programming Languages50 Questions
Exam 2: Basic Elements of C++50 Questions
Exam 3: Input/Output50 Questions
Exam 4: Control Structures I (Selection)50 Questions
Exam 5: Control Structures II (Repetition)50 Questions
Exam 6: User-Defined Functions50 Questions
Exam 7: User-Defined Simple Data Types, Namespaces, and the string Type50 Questions
Exam 8: Arrays and Strings50 Questions
Exam 9: Records (structs)50 Questions
Exam 10: Classes and Data Abstraction50 Questions
Exam 11: Inheritance and Composition50 Questions
Exam 12: Pointers, Classes, Virtual Functions, Abstract Classes, and Lists50 Questions
Exam 13: Overloading and Templates50 Questions
Exam 14: Exception Handling50 Questions
Exam 15: Recursion50 Questions
Exam 16: Linked Lists50 Questions
Exam 17: Stacks and Queues50 Questions
Exam 18: Searching and Sorting Algorithms50 Questions
Exam 19: Binary Trees50 Questions
Exam 20: Graphs50 Questions
Exam 21: Standard Template Library (STL)50 Questions
Select questions type
The recursive algorithm must have one or more base cases,and the general solution must eventually be reduced to a(n)____________________.
(Short Answer)
4.9/5
(84)
int recFunc(int num)
{
if (num >= 10)
return 10;
else
return num * recFunc(num + 1);
}
-If every recursive call results in another recursive call,then the recursive function (algorithm)is said to have ____ recursion.
(Multiple Choice)
4.8/5
(79)
int recFunc(int num)
{
if (num >= 10)
return 10;
else
return num * recFunc(num + 1);
}
-A recursive function in which the last statement executed is the recursive call is called a(n)____ recursive function.
(Multiple Choice)
4.8/5
(73)
The following is an example of a recursive function,where nextNum is a function such that nextNum(x)= x + 1.
int recFunc(int x)
{
return nextNum(nextNum(x));
}
(True/False)
4.9/5
(84)
int puzzle(int start, int end)
{
if (start > end)
return start - end;
else if (start == end)
return start + end;
else
return end * puzzle(start + 1, end - 1);
}
-Consider the accompanying definition of a recursive function.What is the output of the following statement? cout << puzzle(3,7)<< endl;
(Multiple Choice)
5.0/5
(78)
Which of the following rules should you follow to solve the Tower of Hanoi problem?
(Multiple Choice)
4.8/5
(88)
Suppose that function A calls function B,function B calls function C,function C calls function D,and function D calls function A.Function A is then ____________________ recursive.
(Short Answer)
4.9/5
(91)
Showing 41 - 50 of 50
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)