News for hackers. Stuff that matters.
Re:Dijkstra was right – recursion should not be difficult by writeslowly on Monday August 07, 2017 @03:28PM (#14950450)
I think this would be a better lead in than jumping straight to explaining where recursion is useful. Personally, I found it much easier to understand recursion once I had spent enough time experimenting with recursive functions to understand how to convert any algorithm between loop structures and recursive functions.

Trying to understand why I'd want to use one over the other followed from that.

Re:Dijkstra was right – recursion should not be difficult by TheOtherHobbes on Tuesday August 08, 2017 @03:10AM (#14955221)
The problem is most introductions to recursion teach the syntax and implementation, not the conceptual structure.

The syntax is (usually) "a function calls itself, and there's a stack which can cause problems, except in some languages, probably."

The conceptual structure is "Solve a complicated problem by finding a single algo that successfully attacks the problem repeatedly, making the unsolved/unprocessed part smaller and smaller. Repeat until there is no unsolved/unprocessed part left."

Then illustrate with examples like Hanoi that demonstrate how simple logic applied over and over solves a complex puzzle.

Of course it's easy to introduce recursion with factorials, but factorials (etc) don't really explain why recursion is powerful.

They make it look like "Work out this simple math problem (which would be even easier with a for-loop, but whatever) with this one neat trick."