Understanding Recursion
- 94Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
94 questions
- 1Recursion is a method or function that_____.
Hint
Think about what makes a recursive method different from one that only calls other methods.
Answer
calls itself
- 2A recursive call should change or progress a parameter so that each invocation moves closer to the_____.
Hint
This is the condition that stops further recursive calls.
Answer
base case
- 3The condition that tells a recursive function when to stop making further recursive calls is the_____.
Hint
It is also called the stopping condition.
Answer
base case
- 4The small unit of work performed during a recursive invocation helps move the solution closer to the_____.
Hint
It is the problem's desired outcome.
Answer
goal
- 5In the line analogy, each person can find their position by asking the person ahead of them and adding_____for themselves.
Hint
Each person counts as one person in the line.
Answer
one
- 6In the line-position example, the recursion stops when a person has no next person ahead; this is represented by_____.
Hint
It indicates that there is no next person.
Answer
null
- 7In essay revision, each invocation revises the essay and calls itself again until the essay is_____.
Hint
The professor stops requesting revisions at this point.
Answer
complete
- 8The smallest input for reversing a string can be the_____because reversing it produces the same value.
Hint
It contains no characters to rearrange.
Answer
empty string
- 9A single character is also a valid palindrome base case because reading it forward or backward gives the_____.
Hint
There is only one character to compare.
Answer
same character
- 10A recursive algorithm can solve a large problem by breaking it into smaller_____.
Hint
These are reduced versions of the original problem.
Answer
subproblems
- 11In the line-position example, each person passes the question along to the person in_____of them.
Hint
This person is closer to the ATM.
Answer
front
- 12A recursive process needs a condition that prevents the number of active recursive calls from growing_____.
Hint
Without a stopping condition, calls continue indefinitely until resources are exhausted.
Answer
without end
- 13A benefit of recursion is that it can make algorithms for inherently recursive data structures more_____.
Hint
It can reduce complicated loops and variables to a concise solution.
Answer
elegant
- 14Recursive calls can incur CPU overhead compared with iterating through a_____.
Hint
This is the iterative alternative mentioned in the content.
Answer
loop
- 15Recursion can reduce the need for complex loops and auxiliary data structures by using an implicit_____.
Hint
Method invocations are stored on this structure.
Answer
stack
- 16Too many active recursive calls can exhaust the program's available call-stack memory and cause a_____.
Hint
This exception occurs when the call stack exceeds its allocated memory.
Answer
Stack Overflow
- 17Storing results from expensive recursive calls so they can be reused is called_____.
Hint
It avoids repeating work that has already been done.
Answer
memoization
- 18Using recursion without a suitable way to divide the task into meaningful subproblems can lead to unnecessarily_____code.
Hint
The code becomes harder to understand rather than simpler.
Answer
complex
- 19Recursion is especially suitable for data structures that are themselves recursively defined, such as trees and_____.
Hint
This other structure is often traversed with depth-first search.
Answer
graphs
- 20The tradeoff between recursive calls and iteration can involve both time and_____.
Hint
Recursive calls use memory for their stack frames.
Answer
space
- 21The amount of memory used by recursive calls can grow as additional method invocations are added to the_____.
Hint
Each active invocation has a frame stored here.
Answer
call stack
- 22To decide whether recursion is a good fit, ask whether the problem can be broken into meaningful_____.
Hint
Each should move the solution toward the original goal.
Answer
subproblems
- 23When method A needs the result of method B, A cannot finish its dependent work until B_____.
Hint
The needed value must be available before the caller can continue.
Answer
returns
- 24The operating system uses the call stack to store method invocations as_____.
Hint
Each active method call has one of these.
Answer
stack frames
- 25A stack frame can store information about local variables and the method's_____.
Hint
These are the values passed into a method.
Answer
parameters
- 26A method's stack frame must wait for its dependent calls to complete before it can_____from the stack.
Hint
This is the operation that removes a completed frame.
Answer
pop
- 27After a called method returns, its result is passed back to the method invocation that was_____it.
Hint
That earlier method could not finish until the result arrived.
Answer
waiting for
- 28An infinite recursive function with no base case keeps adding invocations until a_____occurs.
Hint
The call stack eventually exceeds its allocated memory.
Answer
Stack Overflow
- 29After the base case returns, recursive stack frames are evaluated in the reverse order of how they were_____.
Hint
The most recent unfinished call returns before earlier calls.
Answer
called
- 30The call stack helps determine the memory address to which a method should_____its data.
Hint
A caller needs the result of its dependent method.
Answer
return
- 31In recursive string reversal, each call can shrink the input by removing its first_____.
Hint
This is the smallest unit of a string used in the example.
Answer
character
- 32To reverse a string recursively, the removed first character is concatenated_____the result of the recursive call.
Hint
This placement causes characters to appear in reverse order as calls return.
Answer
after
- 33For the input "Hello," recursive reversal first processes the remaining substring after removing_____.
Hint
It is the first character of the example input.
Answer
H
- 34In recursive string reversal, saved characters are returned and concatenated as the calls_____.
Hint
The calls do this after the base case has returned.
Answer
unwind
- 35A palindrome reads the same_____and backward.
Hint
The word's order is unchanged when read in either direction.
Answer
forward
- 36A recursive palindrome check compares characters at opposite_____of the string.
Hint
One is near the beginning and the other near the end.
Answer
indices
- 37If opposite-end characters in a palindrome check do not match, the function can immediately return_____.
Hint
The mismatch violates the palindrome property.
Answer
false
- 38An empty string and a one-character string are palindrome base cases that return_____.
Hint
Neither input contains a mismatched pair of characters.
Answer
true
- 39In the palindrome example "race car," matching outer characters allows the function to recurse on a_____substring.
Hint
The matching characters are no longer needed for the next comparison.
Answer
smaller
- 40In decimal-to-binary conversion, repeatedly dividing by two produces a quotient and a_____.
Hint
This value records whether the current number is even or odd.
Answer
remainder
- 41When converting a decimal number to binary recursively, the remainder from division by two contributes one_____.
Hint
It is either zero or one.
Answer
binary digit
- 42For the recursive binary conversion described, reaching zero means there is no need to_____again.
Hint
Zero is the stopping condition for the process.
Answer
divide
- 43In the binary conversion example, the quotient is obtained by dividing by two and applying the_____operator.
Hint
It keeps the result as an integer rather than a floating-point value.
Answer
floor
- 44The sum of natural numbers from one to ten is_____.
Hint
Add each integer from one through ten.
Answer
55
- 45For recursive summation, an input of one is a base case because the sum from one to one is_____.
Hint
There is only a single value to add.
Answer
one
- 46To recursively sum values up to a larger number, add the current number to the sum for the number_____.
Hint
This makes the recursive input progress toward one.
Answer
one less
- 47The Fibonacci sequence is defined so that each value after the base cases is the sum of the_____values.
Hint
For example, 55 comes from 34 and 21.
Answer
two preceding
- 48In the Fibonacci example, the values at indices zero and one are the base cases_____and one.
Hint
It is the first value in the sequence shown.
Answer
zero
- 49In the non-optimized recursive Fibonacci function, the call for one side of the sum must finish before the call for the_____side begins.
Hint
The first call is evaluated before the other operand of the addition.
Answer
right
- 50Recomputing the same Fibonacci values in multiple branches is_____work.
Hint
These calculations have already been performed elsewhere in the recursion tree.
Answer
redundant
- 51A divide-and-conquer algorithm splits a large problem into smaller subproblems, solves them, and then_____their results.
Hint
The results are brought together to solve the overall problem.
Answer
merges
- 52Binary search requires its input list to be_____.
Hint
The ordering lets the algorithm discard half of the search space.
Answer
sorted
- 53Binary search compares the target with a value at the_____of the current search range.
Hint
This value separates the current range into two halves.
Answer
midpoint
- 54If the target is less than the midpoint value in binary search, the algorithm can discard the_____half.
Hint
The sorted order places smaller values on the other side.
Answer
right
- 55If the target is greater than the midpoint value in binary search, the algorithm searches from the midpoint_____.
Hint
The midpoint and everything before it can be excluded.
Answer
plus one
- 56Binary search can stop successfully when the midpoint value equals the_____.
Hint
This means the sought value has been found.
Answer
target
- 57Merge Sort continues dividing an array until each subarray contains just_____value.
Hint
A subarray of this size is already sorted.
Answer
one
- 58During the merge phase of Merge Sort, two sorted subarrays are combined by repeatedly selecting the_____front value.
Hint
This keeps the combined output in ascending order.
Answer
smaller
- 59A temporary array in Merge Sort holds merged values so the original array is not modified prematurely; the values are then copied back into the_____.
Hint
This is the input structure being sorted in place.
Answer
original array
- 60In Merge Sort, the left recursive half is completed before the algorithm starts processing the_____half.
Hint
Recursive calls are evaluated in order, not simultaneously.
Answer
right
- 61A linked list stores its elements through node connections rather than requiring them to be_____in memory.
Hint
The nodes may be located in different memory locations.
Answer
contiguous
- 62For recursive linked-list reversal, a null head or a head with no next node is a_____.
Hint
No further reversal work is needed for either input.
Answer
base case
- 63In recursive linked-list reversal, the call advances through the list by passing_____as its next input.
Hint
This is the pointer to the next node.
Answer
head.next
- 64After the recursive reversal reaches the last node, that node is returned as the new_____.
Hint
It becomes the first node of the reversed list.
Answer
head
- 65When unwinding recursive linked-list reversal, the current node's next node is made to point_____.
Hint
This reverses the direction of the link.
Answer
back to the current node
- 66After reversing a pair of linked-list nodes, the current node's old next pointer is set to_____to prevent a cycle.
Hint
The old forward connection must be removed.
Answer
null
- 67When recursively merging two sorted linked lists, if one head is null, the function can return the_____list.
Hint
There are no nodes from the empty list to merge.
Answer
other
- 68To merge two sorted linked lists recursively, compare their current values and attach the_____node first.
Hint
Choosing it preserves ascending order.
Answer
smaller
- 69In recursive linked-list merging, each selected node's next pointer is assigned the result of the_____merge call.
Hint
That call processes the remaining nodes.
Answer
recursive
- 70For a binary search tree, each node can have at most_____children.
Hint
They are referred to as the left and right children.
Answer
two
- 71In a binary search tree, values in a node's left subtree are_____than that node's value.
Hint
This ordering determines the direction taken when searching or inserting.
Answer
less
- 72In a binary search tree, values in a node's right subtree are_____than that node's value.
Hint
This is the opposite ordering from the left subtree.
Answer
greater
- 73When inserting into a binary search tree, comparisons continue until the insertion position is a_____.
Hint
A new node is inserted at an available child position.
Answer
null
- 74If a value to insert is greater than the current binary search tree node, recursion proceeds to the_____subtree.
Hint
Greater values are placed on this side.
Answer
right
- 75If a value to insert is less than the current binary search tree node, recursion proceeds to the_____subtree.
Hint
Smaller values are placed on this side.
Answer
left
- 76After recursively inserting a node into a binary search tree, the function returns the original_____.
Hint
Returning it preserves access to the tree that was passed in.
Answer
root node
- 77A leaf node is a tree node with no_____.
Hint
It has neither a left nor a right child.
Answer
children
- 78A depth-first traversal explores one subtree fully before exploring the other; in the described tree traversal, it explores the_____subtree first.
Hint
The traversal then proceeds to the right subtree.
Answer
left
- 79To avoid revisiting nodes in a graph that may contain cycles, depth-first search keeps a set of_____nodes.
Hint
The set records nodes already encountered.
Answer
visited
- 80In graph depth-first search, a null input node cannot contain an integer goal, so the search returns_____.
Hint
There is no node to match against the goal.
Answer
false
- 81In graph depth-first search, when the current node matches the goal, the search returns_____.
Hint
The target has been found.
Answer
true
- 82If depth-first search has visited every reachable neighbor without finding the goal, it returns_____.
Hint
The goal was not found in the explored graph.
Answer
false
- 83Memoization stores results of previously computed subproblems so later calls can_____them.
Hint
This avoids repeating expensive calculations.
Answer
reuse
- 84In the described memoized Fibonacci implementation, a hash map provides average constant-time access, described as big O of_____.
Hint
The result is written as big O of one.
Answer
one
- 85A memoized recursive function checks whether the cache contains a result before doing the_____calls.
Hint
If the result is already present, those calls can be skipped.
Answer
recursive
- 86After a recursive subproblem is computed in a memoized function, its result is added to the_____.
Hint
Later calls consult this storage.
Answer
cache
- 87Memoization is especially useful when different recursive branches call the same_____.
Hint
The result of this repeated calculation can be reused.
Answer
subproblem
- 88A recursive function is tail recursive when its final return value is just the_____.
Hint
No further operation is performed on its result before returning.
Answer
recursive call
- 89A factorial function that multiplies a value by the result of a recursive call is not tail recursive because work remains after the_____.
Hint
The multiplication must still be performed.
Answer
recursive call
- 90Tail-call optimization can reduce the number of stack frames used by recursive_____.
Hint
It can help avoid stack growth in supported languages.
Answer
calls
- 91To make a recursive call tail-call optimizable, the recursive call should be the_____instruction.
Hint
Nothing should need to be added to its result afterward.
Answer
last
- 92Tail-call optimization is supported mostly by_____programming languages.
Hint
These languages commonly emphasize recursive function definitions.
Answer
functional
- 93Tail-call optimization is not inherent in languages such as Python, Java, and_____.
Hint
The content also notes that support can vary by browser and execution environment.
Answer
JavaScript
- 94Before relying on tail-call optimization, developers should check whether their language, compiler, and execution environment_____it.
Hint
Support is not consistent across languages and platforms.
Answer
support

Ask anything
We've read this whole study set, so questions about it get the best answers.