Between recursion and iteration, which is more efficient?


Recursion and Iteration Difference


Both iteration and recursion are based on a control statement. Iteration uses a repetitive structure. Recursion uses a selection structure. Both iteration and recursion uses repetition. Iteration explicitly uses repetition structure. Recursion always achieves repetition through repeated function cells. Any problem that can be solved recursively can be solved iteratively. Recursion repeatedly invokes function calls and this leads to larger processor time requirement and memory requirement. In iteration this overhead is omitted because no function calls are made, only loop statements are to be executed to achieve repetition. Hence recursion methods more naturally mirrors the problem and results in program that is easy to understand and debug.

Post a Comment

0 Comments