Geeknarrator

post-header

 Lets start with a general definition :

“Recursion occurs when a thing is defined in terms of itself or of its type. Recursion is used in a variety of disciplines ranging from linguistics to logic. The most common application of recursion is in mathematics and computer science, where a function being defined is applied within its own definition.”

Did it makes sense ? No ? Thats OK! Let the geek explain you the concept in a simple manner :

 At ABC.com the board members have asked the CEO to prepare a presentation on company’s achievements, failures and a complete roadmap based on the earlier discussions. 

 

CEO is very happy about the overall performance and excited to present it to the board members. The only problem is the presentation is not prepared, and it will take a week for him to prepare it alone. After giving a thought, he called up his team and asked them to prepare a presentation and he would just added his own slides. The work begins…

 Soon , all the managers started calling their leads for the same. Leads asked junior members in the team to prepare the slides for their work. Finally junior members, started collaborating on a presentation.

 For each team, junior members started completing their work and pass it on to their leads. Leads would do the same and pass it on to their managers. Similarly, at each level employees completed their work and passed it on to their bosses. Finally, a presentation including all the slides from all the teams reached the CEO. CEO was pretty happy with the presentation, and he added his own slides.

Now a presentation was ready to be shared with the board of directors.

So what did you observe in the overall process ? Which was the common task which was recursively performed and ultimately the bigger task got completed ? 

Obviously , the answer is “Prepare a presentation” .

Now, lets compare this with recursion in computer science.

 Below is a simple program for finding the fibonacci sum for a given number :

int Fibonacci(int n) // starts with CEO level
{
    if (n == 0)
        return 0;
    else if (n == 1) // junior member , who does not have any employee under him. So he completes his task.
        return 1;
    else
        return (Fibonacci(n - 1) + Fibonacci(n - 2)); // result from the teams is used by the managers to prepare 
}

 So in general, a given task is called recursively to perform a bigger operation. Recursion has a lot of applications in computer science and hence very important.

Hope this article was helpful. Thanks for visiting.

Kindly share your valuable feedback below. Like/share our page. This will help us improving.

In case its a query, kindly post it and we will get back to you ASAP.

Cheers,

Kaivalya Apte

Previous post
Next post
Related Posts
2 Comments
Leave a Reply

Your email address will not be published. Required fields are marked *