Recursion

I think one of the biggest mistakes in teaching recursion is going into it as if students are going to have a tough time grasping it. My experience is that most students find it intuitive - unless I make a big deal of it, in which case they adjust their expectations of themselves downward.

Examples I don't like

Almost every textbook uses these examples, and many use only these examples. But they're bad examples: It's not obvious to students why they should care about them, they don't represent the cases where recursion is useful, and recursion is the wrong way to address the problems anyway.

The only one of these examples that I recommend at all is the Fibonacci numbers - and then only for the purpose of demonstrating recursion trees. (I generally teach students how to draw recursion trees since I think they need a way of visualizing the process.)

Examples I like

There aren't many good examples of recursion that can be used in an introductory class, so I'm always on the lookout for more. Here are the ones that I think are worth mentioning.

(schedule)