Deck 18: Recursion
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/15
Play
Full screen (f)
Deck 18: Recursion
1
The number of calls to recursively calculate the Fibonacci value of 7 is:
A) 7
B) 13
C) 41
D) 39
A) 7
B) 13
C) 41
D) 39
41
2
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.
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.
from left to right.
3
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.
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.
call a fresh copy of the recursive method to work on a smaller problem.
4
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.
A) disjointed and less detailed.
B) stabilized and more detailed.
C) identical to the original fractal.
D) None of the above.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
5
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.
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.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
6
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.
B) Koch Curve.
C) similar.
D) mirror.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
7
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.
A) it is faster.
B) it requires less memory.
C) it models the problem more logically.
D) All of the above.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
8
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.
B) it is not as intuitive.
C) recursive methods are harder to debug.
D) recursive methods take longer to program.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
9
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).
B) base step(s).
C) recursive call(s).
D) recursion step(s).
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
10
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.
B) they can cause infinite loops or infinite recursion.
C) they are based on a control statement.
D) both gradually approach termination.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
11
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.
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.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
12
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.
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.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
13
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.
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.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
14
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.
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.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck
15
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.
A) level.
B) depth.
C) order.
D) All of the above.
Unlock Deck
Unlock for access to all 15 flashcards in this deck.
Unlock Deck
k this deck