Chapter 25 Recursion Flashcards
Solve 4! recoursive
4! = 432*1 = 24
By what is a recursive subroutine defined?
a recursive is definedin terms of itself
What must a recursive have?
Base Case
General case
What is a base case?
The starting point in recursive subroutine
What is a general case?
4! = 432*1 = 24
in the equation when you multiply 4 with 3 or afterwards 12 with 2 is a general case
How must a recoursive function end?
In the question solving 4! the answer was a simplification normaly it is
4! = 4 * (4-1)! = 43
3! = 3 * (3-1)! = 32
and so on until the base case is reached
What happens each time a subroutine is called?
A frame is pushed onto the stack
What does a stack frame consist of?
A stack frame consists of the return address and the values of the local variables
What happens when a subroutine completes?
The corresponding stack frame is popped off the stack