COMS 250: Exam 3: Recursive Thinking

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/11

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

12 Terms

1
New cards

A ______ function is one that calls intself

recursive

2
New cards

Recursion can be used to:

compute factorials, find GCD’s, traverse linked lists

3
New cards

The _____ algorithm iuses recursion to efficiently sort a list.

quicksort

4
New cards

If a recursive function does not contain a base case, it _______

uses up all available stack memory, causing the program to crash

5
New cards

The _____ of recursion is the number of times a recursive function calls intself

depth

6
New cards

The QuickSort algorithm works on the basis of

two sublists and a pivot

7
New cards

The programmer must ensure that a recursive function does not become:

an endless loop

8
New cards

A recursive function is designated to terminate when it reaches its ________.

base case.

9
New cards

When function A calls function B, which in turn calls function A, this is know as:

indirect recursion

10
New cards

The recursive factorial function calculates the factorial of its parameter, its base case is when the parameter is _______.

zero

11
New cards

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.

12
New cards

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.