Lecture 11: October 18, 2019

Reading: C text, §9
Due: Extra Credit #1: due October 21, 2019; Homework #2, due October 24, 2019

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

UC Davis sigil
Matt Bishop
Office: 2209 Watershed Sciences
Phone: +1 (530) 752-8060
Email: mabishop@ucdavis.edu
ECS 36A, Programming and Problem Solving
Version of October 18, 2019 at 10:57PM

You can also obtain a PDF version of this.

Valid HTML 4.01 Transitional Built with BBEdit Built on a Macintosh