This could be stack or heap space (it depends what it is used in the recursive function). Also there is the possibility to fall into an infinite loop if you call it in a wrong way, which will lead to stack or heap overflow and code hang. Finally, it could sometimes be difficult for someone to understand and analyse the code.
This could be stack or heap space (it depends what it is used in the recursive function). Also there is the possibility to fall into an infinite loop if you call it in a wrong way, which will lead to stack or heap overflow. Finally, it could sometimes be difficult for someone to understand and analyse the code.
Hi,
Does In recursive functions push and pop operations onto stack happens ? I am confused that , fucnction calls itself , so all the current variables are same in called function , so why to store them on stack ?
Does In recursive functions push and pop operations onto stack happens ? I am confused that , fucnction calls itself , so all the current variables are same in called function , so why to store them on stack ?
Having the same name doesn't mean that they share the same address as well. Otherwise recursive functions could not work.
Every time the function calls itself, the stack size is incremented equally to the variables which must be stored in there by the recursive function. If you want to share the load so that the stack will not be overloaded, you also have the heap option, which means that you 'll be using memory as you go dynamically. You can achieve this with memory allocation. C dynamic memory allocation - Wikipedia, the free encyclopedia