+ 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?

27th Dec 2016, 2:43 PM
Nagaraju Kunchala
Nagaraju Kunchala - avatar
1 Resposta
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.
27th Dec 2016, 3:57 PM
Greg Ortiz
Greg Ortiz - avatar