Recursion : behind the code
Recursion is a very popular concept widely used in programming. This approach can be used to solve those type of problems, in which a part of algorithm is to be repeated to get the solution. The discussion of this topic, here, is to clearly understand of how RECURSION works? It will be discussed in two sessions. The first session will simply help you to visualize the working pattern of Recursion and the second will explore the strategy to write algorithms using recursion. Before going through this article, you should have Understanding of control flow of function calls. Basic understanding of what ‘recursion’ is? How stack(internal) is used in C programs. Session 1: visualize recursion Now, to understand this concept, the simplest example is -- program of -- finding factorial of a number. int Factorial (int n) { if (n <= 1) { return 1; } else { // “fact” is an integer variable fact = n * Factorial (n-1) ; return (fact); } } Whe...