Chapter 12 Python

Ace your homework & exams now with Quizwiz!

A function is called from the main function for the first time and then calls itself seven times. What is the depth of recursion?

7

In a recursive solution, if the problem cannot be solved now, then a recursive function reduces it to a smaller but similar problem and

calls itself to solve the smaller problem

What is the second step to take in order to apply a recursive approach?

determine a way to use recursion to solve the problem in all circumstances which cannot be solved without recursion

A base case is not necessary for all recursive algorithms.

false

Recursive algorithms are always more concise and efficient than iterative algorithms.

false

There must be only one function involved in any recursive solution.

false

recursion is sometimes required to solve certain types of problems.

false

What is the first step to take in order to apply a recursive approach?

identify at least one case in which the problem can be solved without recursion

If, in a recursive solution, function A calls function B which calls function C, this is called ________ recursion.

indirect

Which would be the base case in a recursive solution to the problem of finding the factorial of a number. Recall that the factorial of a non-negative whole number is defined as n! where: If n = 0, then n! = 1 If n > 0, then n! = 1 x 2 x 3 x ... x n

n = 0

The base case is the case in which the problem can be solved without

recursion

What defines the depth of recursion?

the number of times the function calls itself

If a recursive solution is evident for a particular problem, and if the recursive algorithm does not slow system performance by an intolerable amount, then recursion would probably be a good design choice.

true

When, in a recursive solution, function A calls function B which, in turn, calls function A, this is known as indirect recursion.

true

Which of the following describes the base case in a recursive solution?

a case in which the problem can be solved without recursion

Recursive functions are ________ iterative algorithms.

less efficient than

recursion is

never required to solve a problem

A recursive function includes ________ which are not necessary in a loop structure.

overhead actions

A problem can normally be solved with recursion if it can be broken down into smaller problems that are identical in structure to the overall problem.

true

A recursive function must have some way to control the number of times it repeats.

true

Each time a function is called in a recursive solution, the system incurs overhead that is not incurred with a loop

true

In many cases it is easier to see how to solve a problem with recursion than with a loop.

false

The process of calling a function requires

several actions to be performed by the computer

A problem can be solved with recursion if it can be broken down into ________ problems.

smaller

If a problem can be solved immediately without recursion, then the recursive function

solves it and returns


Related study sets

Ch 25 Disorders of Renal Function

View Set

The most spoken languages in the world

View Set

vett 116 coursework - wk 5 exposure variables

View Set