100% found this document useful (1 vote)
2K views

Difference Between Recursion and Iteration

Recursion is a process where a function calls itself repeatedly until a base case is reached, using a stack to remember previous function calls. Iteration uses loops to repeat a process without nested function calls, making it generally faster and using less memory than recursion but resulting in longer code. Both recursion and iteration can result in infinite processing if the terminating condition is never met.

Uploaded by

gouse1210
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
2K views

Difference Between Recursion and Iteration

Recursion is a process where a function calls itself repeatedly until a base case is reached, using a stack to remember previous function calls. Iteration uses loops to repeat a process without nested function calls, making it generally faster and using less memory than recursion but resulting in longer code. Both recursion and iteration can result in infinite processing if the terminating condition is never met.

Uploaded by

gouse1210
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Difference between Recursion and Iteration

RECURSION
1. Recursive function is a function that is
partially defined by itself

ITERATIONS
1. Iterative Instructions are loop
based repetitions of a process

2. Recursion Uses selection structure

2. Iteration uses repetition structure

3. Infinite recursion occurs if the recursion

3. An infinite loop occurs with iteration

step does not reduce the problem in a

if the loop-condition test never

manner that converges on some

becomes false

condition.(base case)

4. Recursion terminates when a base case is


recognized

5. Recursion is usually slower then iteration


due to overhead of maintaining stack

6. Recursion uses more memory than

4. Iteration terminates when the loopcondition fails

5. Iteration does not use stack so it's


faster than recursion

6. Iteration consume less memory

iteration

7. Infinite recursion can crash the system

7. infinite looping uses CPU


8. cycles repeatedly

8. Recursion makes code smaller

9. Iteration makes code longer

You might also like