Starting Out with Python, 2e Chapter 13 (Ch.12)

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

A problem can be solved with recursion if it can be broken 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

There can be several functions involved in the recursion.

True

When function A calls function B, which in turn calls function A, it is known as indirect recursion.

True

What is referred to as the recursive case? a. At least one case in which the problem can be solved without recursion b. A way to solve the problem in all other circumstances using recursion c. The way to stop the recursion d. The way to return to the main function

A way to solve the problem in all other circumstances using recursion

What is the first step that needs to be taken in order to apply a recursive approach? a.) Identify at least one case in which the problem can be solved without recursion. b.) Determine a way to solve the problem in all other circumstances using recursion. c.) Identify a way to stop the recursion. d.) Determine a way to return to the main function.

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

A function is called from the main function for the first time. It then calls itself seven times. What is the depth of recursion? a. Eight b. Two c. One d. Seven

Seven

What defines the depth of recursion? a. The length of the algorithm b. The numbers of function calls c. The number of times the function calls itself d. The number of times it goes back to the main function

The number of times the function calls itself

Each time a function is called, the system incurs overhead that is not necessary with a loop.

True

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

True

If the problem cannot be solved now, then a recursive function reduces it to a smaller but similar problem and _____. a. exits b. returns to the main function c. returns to the calling function d. calls itself to solve the smaller problem

calls itself to solve the smaller problem

Function A calls function B, which calls function C, which calls function A. This is called _____ recursion. a. continuous b. direct c. three function call d. indirect

indirect

Recursive functions are _____ iterative algorithms. a. more efficient than b. less efficient than c. as efficient as d. incomparable to

less efficient than

The process of calling a function requires _____. a. a long memory access b. a quick memory access c. several actions to be performed by the computer d. one action to be performed by the computer

several actions to be performed by the computer

A problem can be solved with recursion if it can be broken down into _____ problems. a. smaller b. one-line c. manageable d. modular

smaller

If the problem can be solved immediately without recursion, then the recursive function _____. a. solves it and returns b. Exits c. returns the result d. generates a run-time error

solves it and returns

Recursion is _____. a. never required to solve a problem b. required to solve mathematical problems c. never required to solve string problems d. required to solve some problems

never required to solve a problem

A recursive function includes _____ which are not necessary in a loop structure. a. function calls b. conditional clauses c. overhead actions d. object instances

overhead actions

The base case is a case in which the problem can be solved without _____. a. loops b. if c. objects d. recursion

recursion

What is referred to as the base case? a. At least one case in which the problem can be solved without recursion b. The circumstances to solve the problem using recursion c. The way to stop the recursion d. The way to return to the main function

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

What is the second step that needs to be taken in order to apply a recursive approach? a. Identify at least one case in which the problem can be solved without recursion. b. Determine a way to use recursion in order to solve the problem in all circumstances which cannot be solved without recursion. c. Identify a way to stop the recursion. d. Determine a way to return to the main function.

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

A base case is not necessary for all recursive algorithms.

False

In many cases a solution using recursion is more evident than a solution using a loop.

False

Recursion is required to solve some type of problems.

False

Recursive algorithms are more concise and efficient than iterative algorithms.

False


Ensembles d'études connexes

Anthropology Quiz 2 Chapter 3 +4

View Set

PSI EXAM REVIEW - Property Disclosure

View Set

Case Control Studies: Chapter 8 Epidemiology

View Set

Chapter 2 - Physical Assessment Findings

View Set

Legal and Ethical Aspects of Health Information Management: Chapter 8 Pt Record Requirements Chapter 9 Confidentiality & Informed Consent AND Chapter 10 Access to Health Information, Chapter 11 Specialized Pt Records

View Set