2. 2
Rushdi Shams, Dept of CSE, KUET,
Bangladesh
What is Recursion
A function is called ‘recursive’ if a statement
within the body of a function calls the same
function
Sometimes called ‘circular definition’
8. 8
Rushdi Shams, Dept of CSE, KUET,
Bangladesh
Iteration vs Recursion
1. Both iteration and recursion are based on control
structure. Iteration uses a repitation structure and
recursion uses a selection structure.
2. Both involves in a termination state checking.
3. Both can be run infinitely. (which is of course not
desirable)
4. Recursion is expensive in case of memory and
processing time than iteration.
5. Recursion for many cases makes programs easier.
6. Recursion is the style of stylish programmer.