Lecture 11: October 18, 2019
Reading: C text, §9
Due: Extra Credit #1: due October 21, 2019; Homework #2, due October 24, 2019
- Greetings and felicitations!
- When you upload your file to Canvas, it may append a number. That’s fine.
- For problem 4, there should be one drawn rectangle, and it surrounds the rectangle with the given dimensions.
- Expressing a problem in terms of a simpler version of itself — use n!
- Function calling itself
- Similar to mathematical induction, but backwards
- Structure: base case, recursive case
- What happens if you omit the base case? (Bad things …)
- How it works
- Program stack
- Walk through nfact.c, with n = 4
- Note nfact calls nfact
- Recursive palindrome program
- Go through algorithm, working from outside in
- Write recursive case
- Write base case
- Put them together in ispal.c