Skip to content

Week 4 Notes

  • Reading Ch. 1.7: Recursive Functions (01/06/22)
    • Recursive function: the body calls the function itself
    • Anatomy:
      • Base cases: Conditional statement for situations that are simplest to process
      • Recursive calls: simplify the original problem
    • Recursive leap of faith: treat a recursive call as a functional abstraction, or trust that it will run correctly
    • In exchange for the lack of nuisance of assigning local names (like the iterative approach), recursive functions require the recognition of computational processes
    • Mutual recursion: Two functions involved in a single recursive procedure that call each other
    • Tree recursion: a function that calls itself more than once
  • Lecture 9: Recursion (02/06/22)
    • Iteration is a special case of recursion
      • Recursion → Iteration: Figure out what state must be maintained by the iterative function
      • Iteration → Recursion: The state of an iteration can be passed as arguments (Updates via assignments become arguments to a recursive call)
  • Homework 03: (02-15/06/22)
    • Very hard
  • Lecture 10: Tree Recursion (15/05/22)
    • Tree recursion is highly repetitive because of calling the function with the same arguments happens multiple times, which can be optimized by remembering the results
  • Discussion 03: Recursion (15/07/22)