0% found this document useful (0 votes)
44 views

Difference Between Recursion and Iteration

Recursion uses function calls where a function is defined in terms of calls to itself until a base case is reached, using more memory and potentially crashing due to infinite recursion. Iteration uses loops to repeat processes without nested function calls, making code longer but using less memory and being less prone to infinite loops crashing the system. Both can result in infinite processing if the reducing condition is never met, but recursion is generally slower due to stack overhead while iteration is faster without a stack.

Uploaded by

Halder Subhas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Difference Between Recursion and Iteration

Recursion uses function calls where a function is defined in terms of calls to itself until a base case is reached, using more memory and potentially crashing due to infinite recursion. Iteration uses loops to repeat processes without nested function calls, making code longer but using less memory and being less prone to infinite loops crashing the system. Both can result in infinite processing if the reducing condition is never met, but recursion is generally slower due to stack overhead while iteration is faster without a stack.

Uploaded by

Halder Subhas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

1/11/14 Prof.

Anand Bali Welcomes you: Difference between Recursion and Iteration

Difference between Recursion and Iteration


RECURSION ITERATIONS
Recursive function – is a function that is Iterative Instructions –are loop based

partially defined by itself repetitions of a process

Recursion Uses selection structure Iteration uses repetition structure

Infinite recursion occurs if the recursion An infinite loop occurs with iteration if
step does not reduce the problem in a the loop-condition test never becomes
manner that converges on some condition. false

(base case)

Recursion terminates when a base case is Iteration terminates when the loop-
recognized condition fails

Recursion is usually slower then iteration Iteration does not use stack so it's
due to overhead of maintaining stack 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

anandbali.blogspot.in/2013/04/difference-between-recursion-and.html 1/1

You might also like