1/11
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
A ______ function is one that calls intself
recursive
Recursion can be used to:
compute factorials, find GCD’s, traverse linked lists
The _____ algorithm iuses recursion to efficiently sort a list.
quicksort
If a recursive function does not contain a base case, it _______
uses up all available stack memory, causing the program to crash
The _____ of recursion is the number of times a recursive function calls intself
depth
The QuickSort algorithm works on the basis of
two sublists and a pivot
The programmer must ensure that a recursive function does not become:
an endless loop
A recursive function is designated to terminate when it reaches its ________.
base case.
When function A calls function B, which in turn calls function A, this is know as:
indirect recursion
The recursive factorial function calculates the factorial of its parameter, its base case is when the parameter is _______.
zero
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);
}
}
Five times, counting the initial call.
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);
}
}
Infinite times due to incorrect recursion.