Difference Between Recursion and Iterations



Recursive function is a function that is partially defined by itself

Iterative instruction are loop based repetitions of a process

Recursion uses selection structure

Iteration uses repetition structure

Infinite recursion occurs if the recursion step does not reduce the problem in a manner that converges on some condition.

An infinite loop occurs with iteration if the loop condition test never becomes false

Recursion terminates when a bae case is recognized

Iteration terminates when the loop condition faols

Recursion is usually slower then iteration due to overhead of maintaining stack

Iteration does not use stack so it's faster than recursion

Recursion uses more memory than iteration

Iteration consume less memory

Infinite recursion can crash the system

Infinite looping uses CPU cycles repeatedly

Recursion makes code smaller

Iteration makes code longer

Share Share on Facebook Share on Twitter Share on LinkedIn Pin on Pinterest Share on Stumbleupon Share on Tumblr Share on Reddit Share on Diggit

You may also like this!