Ch 3 recursion
What is recursion?
A programming technique in which a method calls itself.
T/F the call stack never gets very large
F
every recursive function has what two parts, describe them
base case and recursive case. the recursive case is when the function calls itself and the base case is when the function doesn't call itself so it does not enter an infinite loop
check that you can write a recursive function, try a factorial one
check!!!!
what is the cost of recursion and what are two fixes
it can take up alot of memory. rewrite the code to use loops or use tail recursion.
where do function calls go
onto the call stack
whate are the two operations of a stack
push and pop
what is the benefit of recursion
there is no benefit in using recursion, it is used when it makes the program clearer and you could get the same result from using loops