Chapter 18: Recursion

Ace your homework & exams now with Quizwiz!

When a recursive method is called to solve a problem, the method actually is capable of solving only the simplest case(s), or . a. base case(s). b. base step(s). c. recursive call(s). d. recursion step(s).

a. base case(s)

Recursion is often less efficient than iteration because ________. a. it can cause an explosion of method calls. b. it is not as intuitive. c. recursive methods are harder to debug. d. recursive methods take longer to program.

a. it can cause an explosion of method calls.

Fractals that yield an exact copy of the original when a portion of the original image is magnified are called fractals. a. strictly self-similar. b. Koch Curve. c. similar. d. mirror.

a. strictly self similar.

The current method executing is always the method whose activation record is ________. a. at the bottom of the stack. b. at the top of the stack. c. never placed on the stack. d. second from the top of the stack, just below the previous method call.

b. at the top of the stack

The recursion step should: a. check for the base case. b. call a fresh copy of the recursive method to work on a smaller problem. c. make two calls to the recursive method. d. iterate until it reaches a termination condition.

b. call a fresh copy of the recursive method to work on a smaller problem.

The operands of an operator are evaluated ________. a. from right to left. b. from left to right. c. at the same time. d. in an order that is specific to each operator.

b. from left to right

After a fractal's pattern is applied several times, the shape of the fractal will generally become ________. a. disjointed and less detailed. b. stabilized and more detailed. c. identical to the original fractal. d. None of the above.

b. stabilized and more detailed.

The number of calls to recursively calculate the Fibonacci value of 7 is: a. 7 b. 13 c. 41 d. 39

c. 41

Which of the following statements about recursion are true? a. Recursion can occur infinitely. b. Recursion uses a termination test. c. Both a and b. d. Neither a nor b.

c. both a and b

Recursion often is preferable to iteration because ________. a. it is faster. b. it requires less memory. c. it models the problem more logically. d. All of the above.

c. it models the problem more logically

When the recursion step executes: a. this is known as indirect recursion. b. all of the computer's processes halt until the recursion step has completed executing. c. the original call to the method is still active. d. All of the above.

c. the original call to the method is still active

All of the following are true for both recursion and iteration except ________. a. they have a base case. b. they can cause infinite loops or infinite recursion. c. they are based on a control statement. d. both gradually approach termination.

a. they have a base case.

Which of the following is false? a. Since BigInteger is not a primitive type, we can't use the arithmetic, relational and equality operators with BigIntegers. b. BigInteger method compareTo compares the BigInteger number that calls the method to the method's BigInteger argument, and returns -1 if the BigInteger that calls the method is less than the argument, 0 if they're equal or 1 if the BigInteger that calls the method is greater than the argument. c. The value 1 can be implicitly converted to a BigInteger. d. BigInteger can represent integer values larger than what primitive type long can represent.

c. the value 1 can be implicitly converted to a BigInteger.

A recursive method . a. is a method that calls itself. b. can be called directly. c. can be called indirectly through another method. d. All of the above.

d. All of the above.

In recursive backtracking, if one set of recursive calls does not result in a solution to the problem, what happens? a. The program returns to a previous decision point and makes a different decision. b. The program backs up to the previous decision point and throws an exception. c. The program continues, with unexpected results. d. The program backs up to the original method call.

d. The program backs up to the original method call.

Each time a fractal's pattern is applied to it, the fractal is said to be at a new ________. a. level. b. depth. c. order. d. All of the above.

d. all of the above


Related study sets

Ch. 14 Workers Compensation Insurance

View Set

Chapter 12: The Postpartum Woman

View Set

4203 xam 2 all review/eaq questions

View Set

LearningCurve 13b. Social Influence

View Set

Marketing chapter 13 practice questions

View Set

Phar431: Bioavailability/Bioequivalence (4/9/15)

View Set