4 ms·
When learning recursion, there aren't much practice problems people do in imperative languages. Most of the imperative languages don't have tail call optimizati
by irahul 16y ago
When learning recursion, there aren't much practice problems people do in imperative languages. Most of the imperative languages don't have tail call optimization and the prevalent culture is to use iteration.
That said, there are some problems for which the iterative solution won't be straight forward viz. quicksort, mergesort, binary tree traversal etc etc. But the issue is when a student not very familiar with recursion stumbles upon these, he has a hard time understanding them.
I learned recursion and manual recursion removal in C. I already understood recursion when I read "The Little Schemer", but it still managed to change my perception. I highly recommend it, regardless of whether you are going to work in Scheme(most likely no) or not.
- cygwin98 16y agoSame experience here, though I learned recursion in Pascal. Maybe it's just me, it just feels awkward when you do recursion in imperative languages. For the past two years, I've been playing/working with functional languages, firstly Erlang or more recently F#, as well as functional programming in C#, and start to appreciate the power of FP. Recursion is also used more often as it just feels natural there when you do recursion in FP.
- SkyMarshal 16y ago/second TLS. Most of the book is on recursion, and uses a Socratic teaching method to both explain and reinforce it brilliantly.