0% found this document useful (0 votes)
2 views

Class8 9 Recursive Programming 19 24 Jan2024

Uploaded by

8888songoku
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Class8 9 Recursive Programming 19 24 Jan2024

Uploaded by

8888songoku
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 32

Recursive

Programming
A FUNCTION CALLING
ITSELF!
Definition
Types of recursive functions

Types

Direct Indirect No Tail/ Head Linear Tree


Tail Recursion
Recursion Recursion Recursion recursion Recursion
Direct recursion: A function calls itself
within the same function repeatedly
What happens in the memory?
Indirect recursion: A function is mutually
called by another function in a circular
manner
Tail recursion: recursive call is the last
statement executes by the function.
Non-tail/Head recursion: the recursive
call will be the first statement in the
function.
Linear recursion: the function makes a
single call to itself at each time the function
runs and grows linearly in proportion to the
size of the problem.
Tree recursion: the function makes more
than one call to itself within the recursive
function
Things to take care:
1. Recursive case
2. Base condition
Recursive program to find factorial of a
number
Recursive program to find Fibonacci
series
Find GCD of two numbers
Analyzing algorithms
Binary search
Tower of Hanoi

You might also like