components involved in recursion
I am a university student doing a final year project. my lecturer ask me to draw out all the components involved in recursion but i have no idea what is involved. She told me that STACK is one of them because all the values need to be stored into it when recursion is done. Apart from that, i have no idea what other components are. Pls help me with this. I need it URGENTLY..!! Thanks.
[393 byte] By [
ah_aia] at [2007-10-1 23:42:29]

http://www.answers.com/recursionwill get you started; once you know what's involved, post again.
i understand what is recursion.. just that i don know the exact components involved for it.. can you pls give me some clues.. i really need it.. thanks..
ah_aia at 2007-7-15 15:32:46 >

> I am a university student doing a final year project.
> my lecturer ask me to draw out all the components
Just a guess, components:
stack, initialization, base case, recursive step, input data, output data,
http://en.wikipedia.org/wiki/Recursion
http://www.google.ca/search?hl=en&safe=off&q=%22components+of+recursion%22&meta=
can you describe more details for that? like why it is needed and what it is for.. thanks =)
ah_aia at 2007-7-15 15:32:46 >

> can you describe more details for that? like why it
> is needed and what it is for.. thanks =)
Details are already provided in numerous links.
What is it _exactly_ that you don't understand about recursion? Reading the provided links and Googling for some code-samples on recursion will give you more than enough information. As a university student in his/her last year, surely you're able to do some research on your own.
Keywords:
- fibonacci numbers
- tower of hanoi
- factorial calculation
Good luck.
Recursion is like Trinity of Gods in Hindu Mythology. Brahma the creator, Vishnu the propagator and Shiva the destroyer.
You need to have an exit criteria to return to caller.
If the exit criteria is not met you propagate further
(yes stack is kept here by OS)
When you have done you either input/output stuff in between depending on the need. But these three things are always necesaary.
int f;
int factorial(int f,int i)
{
if(i<=0) return f;
int intermediate_result= f * factorial(f-1);
return intermediate_result;
}
Recursion is like Trinity of Gods in Hindu Mythology. Brahma the creator, Vishnu the propagator and Shiva the destroyer.
You need to have an exit criteria to return to caller.
If the exit criteria is not met you propagate further
(yes stack is kept here by OS)
When you have done you either input/output stuff in between depending on the need. But these three things are always necesaary.
int f;
int factorial(int f,int i)
{
if(i<=0) return f; /*exit criteria*/
int intermediate_result= f * factorial(f-1);/*propagation*/
return intermediate_result;/*return */
}