7
zwen
7y

Is it normal to have a hard time thinking recursively? Gah!

Comments
  • 8
    Re-read the original post, then this comment again.
  • 4
    thinkharder(thinkharder());

    Ooops stack overflow in thinkharder()
  • 1
    I used to struggle with it a lot too. Problem is thinking of it linearly stsrt to finish. Rather, think of it need to result. I need this, ok well I have this I need to keep track of, alright it needs to change every iteration... Write some business logic conditionals, call function inside itself, pass thing you need to keep track of, make sure to always hit a return statement
  • 1
    Actually for some problems recursion is actually the easiest way to think about it (usually searching algorithms). But you do need to get comfortable with it.
Add Comment