3 ms·
I have to diagree with your PoV for recursion. I personally don't have any problems if an alogrithm is iterative or recursive, specially if the recursivity is a
by m0skit0 14y ago
I have to diagree with your PoV for recursion. I personally don't have any problems if an alogrithm is iterative or recursive, specially if the recursivity is as simple as in your example. In fact, in such cases recursivity is even simpler to understand than iteration IMHO.
- johnbender 14y agoI came here to say something similar. I would go further and assert that once you're comfortable with recursion it's nearly always preferable where reasoning about execution is the primary concern. Discarding the mental overhead associated with index accounting and temporary variable state has a lot of value.