Starting Out with Python, 3e Ch 12

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

What is a base case?

A case in which the problem can be solved without recursion

It is said that a recursive algorithm has more overhead than an iterative algorithm. What does this mean?

A recursive algorithm requires multiple method calls. Each method call requires several actions to be performed

In the base case, a recursive method calls itself with a smaller version of the original problem. T or F

False

When function A calls function B, which calls function A, it is called ______ recursion. a. implicit b. modal c. direct d. indirect

indirect

It is not necessary to have a base case in all recursive algorithms. T or F

False

Some problems can be solved through recursion only. T or F

False

What is direct recursion?

In direct recursion, a recursive method calls itself

What is indirect recursion?

In indirect recursion, method A calls method B, which in turn calls method A.

The part of a problem that can be solved without recursion is the ______ case. a. base b. solvable c. known d. iterative

base

A recursive function ______. a. calls a different function b. abnormally halts the program c. calls itself d. can only be called once

calls itself

When a function explicitly calls itself it is called _______ recursion. a. explicit b. modal c. direct d. indirect

direct

A function is called once from a program's main function, and then it calls itself four times. The depth of recursion is ______. a. one b. four c. five d. nine

four

Any problem that can be solved recursively can also be solved with a ______. a. decision structure b. loop c. sequence structure d. case structure

loop

a function that calls itself

recursive function

A recursive algorithm must ______ in the recursive case. a. solve the problem without recursion b. reduce the problem to a smaller version of the original problem c. acknowledge that an error has occurred and abort the program d. enlarge the problem to a larger version of the original problem

reduce the problem to a smaller version of the original problem

Actions taken by the computer when a function is called, such as allocating memory for parameters and local variables, are referred to as ______. a. overhead b. set up c. clean up d. synchronization

set up

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

smaller problems

A recursive algorithm must ______ in the base case. a. solve the problem without recursion b. reduce the problem to a smaller version of the original problem c. acknowledge that an error has occurred and abort the program d. enlarge the problem to a larger version of the original problem

solve the problem without recursion

The number of times that a function calls itself is known as

the depth of recursion

The part of a problem that is solved with recursion is the _______ case. a. base b. iterative c. unknown d. recursion

iterative

What is a recursive case?

Cases in which the problem is solved using recursion

Fibonacci series

The Fibonacci numbers, named after the Italian mathematician Leonardo Fibonacci, are a sequence of numbers that after the second number, each number in the series is the sum of the two previous numbers.

the process of calling a function requires several actions to be performed by the computer. These actions include allocating memory for parameters and local variables and storing the address of the program location where control returns after the function terminates.

These actions, which are sometimes referred to as overhead, take place with each function call. Such overhead is not necessary with a loop.

An algorithm that uses a loop will usually run faster than an equivalent recursive algorithm. T or F

True

What causes a recursive algorithm to stop calling itself?

When it reaches the base case


Kaugnay na mga set ng pag-aaral

Ch 44 Thyroid and Antithyroid Drugs

View Set

9.15 Windows Boot Process & Startup Error Fixes

View Set

American History Chapters 10, 11, and 12 Study Guide

View Set

cGenomics_ lec4b_Sequencing_techonology

View Set

Revel Communication Ch. 1-2 quizzez

View Set

CHM 130 Lesson 7; Chemical Reactions

View Set