CS Week 9 - Recursion Flashcards
algorithm
a sequence of steps for solving a problem
recursive algorithm
an algorithm that breaks the problem into smaller subproblems and applies the same algorithm to solve the smaller subproblems
base case
how to actually do something
where the recursion ends
recursive function
a function that calls itself
creating a recursive function
1.write the base case
returns a value without performing a recursive call
2.write the recursive case
a few that can be solved with recursion
Fibonacci sequence
greatest common divisor
binary search
finding all possible combinations
finding all possible subsets of a set of items
finding all possible paths
stack frame
for local parameters, local variables, and more function items
Upon return, the frame is deleted
stack overflow
meaning a stack frame extends beyond the memory region allocated for stack
binary search
algorithm begins at the midpoint of the range and halves the range after each guess