1 / 8

Recursion and Recursive Function in C | C Tutorial for Beginners | C Progr

This presentation on Recursion in C will help you understand one of the most important aspects of Programming ie. Recursion. Understand how to create a Recursive Function.<br><br>1. What is Recursion?<br>2.u200b Working of Recursion<br>3.u200b Types of Recursion<br>4.u200b Advantages and Disadvantages<br><br>Learn more at: https://www.simplilearn.com/pgp-full-stack-web-development-certification-training-course?utm_campaign=C &utm_medium=Description&utm_source=Slideshare<br>

Simplilearn
Download Presentation

Recursion and Recursive Function in C | C Tutorial for Beginners | C Progr

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What’s in it for you ? What is Recursion ? Working of recursion Types of recursion Advantages and Disadvantages

  2. What is Recursion ? Syntax : Void recursion() { recursion(); } Int main() { recursion(); } A function calling itself again and again until a certain condition is met is known as recursion

  3. Click here to watch the video

  4. Working of recursion Factorial of 5 : return 5*factorial(4) = 120 return 4*factorial(3) = 24 return 3*factorial(2) = 6 return 2*factorial(1) = 2 return 1*factorial(0) = 1 Recursion performs repetition on the function calls and it stops the execution when the base case becomes true. A base condition should be defined in the recursive function To understand this let’s take an example

  5. Types of recursion Direct recursion Indirect recursion When a function calls itself indirectly from other function then this type of recursion is called Indirect recursion Example : When a function calls itself directly then it is known as a direct function Example : void recursion( ) { recursion(); } void sub() { recursion(); } void recursion() { sub(); }

  6. Advantages and Disadvantages • The recursive program has greater space requirements than the iterative program • It also has greater requirement of time because of function calls • it provides a simple and clean way to write a code • Recursion is more preferred in problems like tree traversals, tower of Hanoi, Advantages Disadvantages

More Related