Problem solving with programming: Explaining recursion with a simple example
In this post we will see a simple example which explains the concept of recursion.
Recursion is nothing but defining a problem in terms of itself. For example let us consider the problem of finding the sum of all the elements in an array. We can define the problem as follows.
Let sum(array,n) denotes the sum of the elements of an array of size n.
We can define sum(array,n) = sum(array,n-1) + array[n]
Read full article from Problem solving with programming: Explaining recursion with a simple example
No comments:
Post a Comment