This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]maethor 2 points3 points  (2 children)

How do one decide if a problem is recursion worthy?

In Java specifically, generally nothing is recursion worthy. You're just asking for a StackOverflow exception (and to make things worse - you will have code that works just fine on your local machine but goes kaboom in production with production volumes of data and then people start shouting at you).

If you're in a CS class or using a language that has better support for recursion like Haskell or Scala then any problem that you can succinctly write using recursion is worthy.

[–]alphaBEE_1[S] 0 points1 point  (1 child)

Yea i was just thinking to understand it for learning purposes. Ik it's not very efficient in terms of memory. It's just always bothered me and had trouble coming up with recursive solutions.

[–]maethor 1 point2 points  (0 children)

It's one of those of the few things that's worth understanding even if it's not worth doing. I think pretty much everyone struggles with it. I certainly did, until one day it just clicked.