CS172 Supplementary Material

Understanding Recursion

The material in this paper provides you with a complete picture of how recursion works and how it's used through four representative examples. Those examples include factorial, balanced parentheses, list appending, and the Towers of Hanoi puzzle.

In-class Code

Please note: The code in these examples is what was written in class to go along with our discussions there. It should not be taken as examples to be followed, but rather as bits of explanatory material. I've elided those bits that were inserted in the course of discussion that would prevent thse file from compiling, and have done a couple of minor cleanups from the versions last projected in the classroom.