Intro CS Assignments
Assignments by week:
Fall Term:
Winter Term:
Spring Term:
Thursday, October 18
Description
Recursion: An Introduction to Recursion: Recursion
Homework
  • Search for "recursion" on Google. Notice anything?
  • Read Introduction to Recursion. You only need to read through the page marked 183 (until the section heading "5.3 The Fibonacci function"). You're welcome to read more if you're interested.
Friday, October 19
Description
Homework
  • Using the following code as a starting point, make a program that fills the screen progressively smaller rectangles. However, you may not use loops, and you may not remove the noLoop() line from the code (in other words, you must use recursion)! You should define at least one additional function in your code.

    void setup() {
      size(800,800);
      noLoop(); // don't disable this!
      noFill();
      stroke(0);
      rectMode(CENTER);
    }
    
    void draw() {
      // call your function here
    }
    
    // define your function here
    
  • Optional: Go back to your Forest lab and create a recursive tree function based on the sample recursive tree on the processing web site. Additional features you might want to try and add:
    • A randomized branching angle (since it can't depend on the mouse).
    • Lines that get thinner as the branching progresses (that is, have a thick trunk and skinny twigs at the ends).
    • Different colors as you progress through the branching.
    • Leaves at the end of the branches.