I always avoid recursion at any cost. Most of the time you can rewrite the code without recursion.
Recursion is hiding the code constructs and is incredibly hard to debug. You may understand it at this moment, but as your program ages, languages change, syntax change, it is going to kick your ass big.
2 comments
0 u/roznak 22 Mar 2017 18:36
I always avoid recursion at any cost. Most of the time you can rewrite the code without recursion.
Recursion is hiding the code constructs and is incredibly hard to debug. You may understand it at this moment, but as your program ages, languages change, syntax change, it is going to kick your ass big.
My advice: avoid them.
0 u/coder007 [OP] 23 Mar 2017 16:32
but it is fun though.. and these are interview questions not real world problems.. candidate is expected to know recursion :)