Compare Iterative and Recursive Functions?


ITERATIVE FUNCITONS

RECURSIVE FUNCTIONS
  A)
The process is repeated until a condition is satisfied

   A)
The  function repeatedly calls itself till the terminating condition is satisfied.
  B)
The sts included in the loo are executed repeatedly

   B)
The intermediate results are stored on to the stalk each time the function recursively called
  C)
Each time the loop is executed, the intermediate results are refined

   C)
The final value will be evaluated often retrieving the values stored on the stack

Ex: int gcd ( int a, int b)
{
int r;
r = a%b;
while ( r!=0)
{
a=b;
b=r;
r=a%b;
}
return b;
}

Ex: int gcd ( int a, int b)
{
int r;
r =a%b;
if ( r==0)
return b;
else
gcd ( b,r);
}

Related

What is Type Conversion? Explain its Types?

Converting one data into another is called type conversion. In ‘C’ language type conversions are done in 2 ways. 1. Implicit type conversion. 2. Explicit type conversion...

Write about Different Categories of Functions in C?

A function depending on whether rays are present or not and whether a value is returned or not, may belong to one of the follow categories. Categories: 1: Function wit...

Write about Formatted input/output Functions in C

Reading data from input device and displaying the result on the screen are the two main tasks of any programming. In ‘C’ language the input output operations are carried out by u...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item