Chapter 15 Recursive

Ace your homework & exams now with Quizwiz!

2. This is the part of a problem that can be solved without recursion.

Base case

15.3 What is a recursive case?

Cases in which the problem is solved using recursion.

4. This is when a method explicitly calls itself.

Direct recursion

10. True or False: In the base case, a recursive method calls itself with a smaller version of the original problem.

False

15.5 What is direct recursion? What is indirect recursion?

In direct recursion, a recursive method calls itself. In indirect recursion, method A calls method B, which in turn calls method A.

______recursion is when method A calls method B, which in turn calls method A.

Indirect

5. This is when method A calls method B, which calls method A.

Indirect Recursion

8. True or False: Some problems can be solved through recursion only.

False

9. True or False: It is not necessary to have a base case in all recursive algorithms.

False

1. A method is called once from a program's main method, and then it calls itself four times. The depth of recursion is

Four

15.4 What causes a recursive algorithm to stop calling itself?

When it reaches the base case.

15.2 What is a base case?

A case in which the problem can be solved without recursion.

15.1 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 by the JVM. These actions include allocating memory for parameters and local variables, and storing the address of the program location where control returns after the method terminates. All of these actions are known as overhead. In an iterative algorithm, which uses a loop, such overhead is unnecessary.

6. This refers to the actions taken internally by the JVM when a method is called.

Overhead

3. This is the part of a problem that is solved with recursion.

Recursion case

7. True or False: An iterative algorithm will usually run faster than an equivalent recursive algorithm.

True

•When recursive methods directly call themselves it is known as _______recursion.

direct

•In many cases, recursive algorithms are less ______ than iterative algorithms.

efficient

When the base case is reached, a recursive method stops calling itself. Without a base case, the method will continue to call itself ______.

infinitely

An ____ algorithm will use looping statements such a for loop, while loop or do-while loop to repeat the same steps while a _____ algorithm, a module (function) call itself again and again until the base condition(stopping condition) is satisfied.

iterative, Recursive

A ______ method is a method that calls itself.

recursive

Like a loop, a recursive method must have some way to control the number of times it _______.

repeats

•Recursion can be a powerful tool for solving ______ problems.

repetitive

•Recursion is never absolutely _____ to solve a problem.

required

•Any problem that can be solved recursively can also be solved _______, with a loop.

iteratively


Related study sets

Microeconomics-Imperfect & Perfect Competition - Test4

View Set

Ch. 7 Wiley Plus Practice Questions

View Set

Medsurg individual quiz (54,55,56,57,58,59)

View Set

Lectura Cultura Asi Se Dice level 2

View Set