• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How would you teach recursion?

Page 2 - Seeking answers? Join the AnandTech community: where nearly half-a-million members share solutions and discuss the latest tech.
Originally posted by: tfinch2
N Queens problem is a perfect first example

I don't think so. It's a little too complex. You don't want something that has too much built in logic. You're trying to teach basic recursion, not how to solve a problem.
 
Ignore all the idiots who believe teaching infinite loops = recursion...


I did a little research, the easiest sort to teach recursion would be a merge sort. Get a deck of cards and pull out all the spades from 2-9, shuffle them up, line them up, and physically show them how recursion works (or create a PPT if you need that as a medium).

EDIT: For their sake, don't use the Tower of Hanoi problem.
 
Originally posted by: joshsquall
Originally posted by: logic1485
For some people, you may have to teach what a factorial is first. I did not know what a factorial is, and yet I did some programming, but I can't remember how I was taught it.

I think it's safe to assume that most people learn factorials in middle school.

And if not, you can explain it in 3 seconds.
 
Back
Top