+ 1
Is recursion is needed
Recursion make code easy , true, but... is it needed? A program or algorithm that can be resolved using recursion, also can be resolved without recursion?
1 Respuesta
0
Most recursive algorithms can be written iteratively, or using only loops. If you look at recursive algorithms, chances are that they have been implemented both recursively and iteratively. However that would be up to the programmer to decide. Sometimes a recursive algorithm is difficult to translate into an iterative implementation.
If you look at algorithms involving graph traversing, trees, and sorting, it might help why they are written as recursive.