Contents

Review of Recursion

Table of Contents

Further Reading

This page requires JavaScript, which you
don't seem to have. Please try a different browser.

Scroll through the page to review your answers. The correct answer is
highlighted in
green.
Your incorrect answers (if any) are highlighted in
red.
If you'd like to take the test over again, click the reset button at the end of the test.

To recurse is to

(A)
Practice recursion

(B)
Swear again

(C)
Neither of the above

To recur is to

(A)
Practice recursion

(B)
Swear again

(C)
Neither of the above

Factorial is

(A)
a good introductory example of recursion, but a function better
implemented iteratively for efficiency reasons.

(B)
a good introductory example of recursion, and a function best
implemented recursively.

(C)
a bad introductory example of recursion as it hard to implement
recursively.

factorial(0) is

(A)
0

(B)
1

(C)
Infinity

(D)
Undefined

(E)
None of the above

Recursion is

(A)
a powerful construct theoretically, but rarely used in actual programs.

(B)
a weak construct theoretically rarely used in actual programs.

(C)
a powerful construct theoretically, often used in certain applications
that benefit from recursive methods.

True or False: When a recursive solution's elegance outweighs its
overhead (memory, time, efficiency, etc), and when it is much less
complex than an iterative solution, you would most likely choose to
use the recursive solution.

(A)
True

(B)
False

True or False: You should always use a recursive solution rather
than an iterative solution when you are sure that that recursive
solution will not overflow the call stack.

(A)
True

(B)
False

Recursion can be an inefficient way to implement a solution because

(A)
using the call stack to store states adds significant overhead.

(B)
calling a function multiple times could be reduced to looping, which
might better done with a looping structure such as a while construct.

(C)
Both of the above.

True or False: Recursion happens when an algorithm does not use a loop.

(A)
True

(B)
False

True or False: A function can be considered recursive if it has a direct
or an indirect call to itself.

(A)
True

(B)
False

True or False: Infinite recursion can occur when a recursive algorithm
does not contain a base case.

(A)
True

(B)
False

True or False: Infinite recursion can occur when a recursive algorithm
contains a base case.

(A)
True

(B)
False

True or False: Infinite recursion can occur when the base case is never
reached by the algorithm.

(A)
True

(B)
False

A solution to a 64-disk Towers of Hanoi problem requires how many disks
to be moved?