COSC 4.2

Ace your homework & exams now with Quizwiz!

Look at the following pseudocode algorithm: What is returned from gcd(60, 24)?

12

To solve a program recursively, you need to identify at least one case in which the problem can be solved without recursion. This is known as the:

Base Case

If the base case in a recursive method is never reached:

Correct The method will call itself indefinitely.

This term is used for methods that directly call themselves.

Direct recursion

[T/F]In Java, it is not possible for a method to call itself.

False

The depth of recursion is:

The number of times that a method calls itself.

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

a loop

Look at the following pseudocode algorithm: What is the recursive case for the algorithm?

x >= 8

Look at the following pseudocode algorithm: What is the base case for the algorithm gcd?

y == 0

A recursive method is:

A method that calls itself.

Which of the following problems can be programmed recursively?

All of these

How many times will the following method call itself if the value 10 is passed as an argument? [IMAGE]

An infinite number of times

This type of method is a method that calls itself.

Recursive

[T/F]A problem can be solved recursively if it can be broken down into successive smaller problems that are identical to the overall problem.

True

[T/F]Any problem that can be solved recursively can also be solved iteratively.

True

[T/F]Recursive algorithms are usually less efficient than iterative algorithms.

True

The part of a problem that is solved with recursion is known as the:

recursive case

Usually, a problem is reduced by making the value of one or more parameters ________ with each recursive call.

smaller

Look at the following pseudocode algorithm: What value is returned for Test14(7)? [IMAGE] .... end Test14

14

[T/F]

If method A calls method B, which in turn calls method A, it is called indirect recursion.


Related study sets

ENVS 2126: Practice ass#8 (Slawomir Lomnicki)

View Set

Demand and Supply, price ceiling, price floor

View Set

Biology: Virus and Bacteria Vocab

View Set

Wordly Wise 3000 book 12 lesson 20

View Set

Monday, November 13th - Summative Assessment

View Set

MDST 1002 - Intro to Social Media Final Exam

View Set

Chapter 1: Doing Comparative Politics

View Set