Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are all problems that are solvable with recursion solvable with loop?

All problems that are solvable with recursion are solvable with loop, and vice versa.

Is this statement right or proven at all? sometimes, using recursion causes stack overflow. if the statement is correct. we'd better use loop instead.

thanks

like image 679
booirror Avatar asked Aug 27 '12 13:08

booirror


1 Answers

Yes. Loop + Stack will solve all recursion problems.

After all, compiler does that internally. Recursion is nothing but pushing data onto a stack, and later popping from it, done by the compiler.

like image 146
Nawaz Avatar answered Sep 17 '22 21:09

Nawaz