-
Junior Member
How Does Recursion Work?
how does stack works when we called a variable storing recursion result
-
Expert Member
Re: How Does Recursion Work?
I am not sure but as my view, stack allocated every time in recrusion and stack size is repetitively increase. For your reference you can understand the exact meaning by the program :
Factorial with recursive and factorial with non recursive implementation
-
Junior Member
Re: How Does Recursion Work?
If we are using a recursive factorial function say FactA()
and put the result in a variable like
int I=FactA(5)
The FactA() will use stact to calculate the factorial and store it in I
and further in program we use the value of the variable then the value store in I Uses
-
Expert Member
Re: How Does Recursion Work?
Hi,
There are two methods recursive and non recursive : If you use stack in recursive method stack allocated every time in recrusion and stack size is repetitively increase. you its a not good practise,,,,,,, A simple example in performance perspective if you use recusive factorial program with more than 12 number then you should not use recusive method.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules