SlideShare a Scribd company logo
8
Most read
13
Most read
14
Most read
Algorithms and Data Structures
Recursion
By- Priyanka
Basic Algorithms: Recursion
Basic Algorithms: Recursion
Basic Algorithms
 Write a function that calculate 3!
(factorial).
 Write a function that calculate n!
Recursion helps
 Avoidance of unnecessary calling of functions.
 A substitute for iteration where the iterative
solution is very complex.
 Extremely useful when applying the same solution.
Types of Recursion
Linear recursion : makes at most one recursive call each
time it is invoked.
Binary recursion : algorithm makes two recursive calls.
Multiple recursion : method may make (potentially more
than two) recursive calls.
Linear Recursion
Algorithm LinearSum(A, n)
if n = 1 then
return A[0]
else
return LinearSum(A, n-1) + A[n-1]
Linear Recursion
A={4, 3, 6, 2, 5}, n=5.
Student Exercise
Can you think of any drawback for recursive
functions?
Answer is related to computer memory
Binary Recursion
Algorithm BinarySum(A, i, n)
if n = 1 then
return A[i]
else
return BinarySum(A, i, [n/2])+
BinarySum (A, i+[n/2], [n/2])
Binary Recursion
Recursion trace for the execution of BinarySum(A, 0, 8) :
Multiple Recursion
Combinatorial puzzle:
pot + pan = bib
dog + cat = pig
boy + girl = baby
Puzzle Solve(3, S, U)
S is an empty sequence/string, and K=3
U = {a, b, c}
Example: Find a solution to cbb + ba = abc, where {a, b, c}
stands for {7, 8, 9}, K=3.
Soluti
on
Thank You
Ad

Recommended

Data Structures- Part5 recursion
Data Structures- Part5 recursion
Abdullah Al-hazmy
 
classes and objects in C++
classes and objects in C++
HalaiHansaika
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
Python: Modules and Packages
Python: Modules and Packages
Damian T. Gordon
 
Recursive Function
Recursive Function
Harsh Pathak
 
Applications of stack
Applications of stack
eShikshak
 
Constructors and Destructors
Constructors and Destructors
Dr Sukhpal Singh Gill
 
Stacks IN DATA STRUCTURES
Stacks IN DATA STRUCTURES
Sowmya Jyothi
 
Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 
Input and output in C++
Input and output in C++
Nilesh Dalvi
 
Divide and conquer
Divide and conquer
Dr Shashikant Athawale
 
Inline function
Inline function
Tech_MX
 
Recursion
Recursion
baabtra.com - No. 1 supplier of quality freshers
 
Tree - Data Structure
Tree - Data Structure
Ashim Lamichhane
 
Introduction to data structure ppt
Introduction to data structure ppt
NalinNishant3
 
Top down parsing
Top down parsing
LakshmiSamivel
 
Trees
Trees
Burhan Ahmed
 
Abstract data types
Abstract data types
Poojith Chowdhary
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
Eduardo Bergavera
 
Functions in c language
Functions in c language
tanmaymodi4
 
Abstract Data Types
Abstract Data Types
karthikeyanC40
 
Python recursion
Python recursion
Prof. Dr. K. Adisesha
 
Automata theory
Automata theory
Pardeep Vats
 
Assembler
Assembler
manpreetgrewal
 
Recursion
Recursion
Abdur Rehman
 
stack & queue
stack & queue
manju rani
 
Hashing Technique In Data Structures
Hashing Technique In Data Structures
SHAKOOR AB
 
Stack and Queue
Stack and Queue
Apurbo Datta
 
Recursive Algorithms with their types and implementation
Recursive Algorithms with their types and implementation
Ahmad177077
 
Recursion.ppt
Recursion.ppt
TalhaHussain58
 

More Related Content

What's hot (20)

Array Introduction One-dimensional array Multidimensional array
Array Introduction One-dimensional array Multidimensional array
imtiazalijoono
 
Input and output in C++
Input and output in C++
Nilesh Dalvi
 
Divide and conquer
Divide and conquer
Dr Shashikant Athawale
 
Inline function
Inline function
Tech_MX
 
Recursion
Recursion
baabtra.com - No. 1 supplier of quality freshers
 
Tree - Data Structure
Tree - Data Structure
Ashim Lamichhane
 
Introduction to data structure ppt
Introduction to data structure ppt
NalinNishant3
 
Top down parsing
Top down parsing
LakshmiSamivel
 
Trees
Trees
Burhan Ahmed
 
Abstract data types
Abstract data types
Poojith Chowdhary
 
Chapter 11 - Sorting and Searching
Chapter 11 - Sorting and Searching
Eduardo Bergavera
 
Functions in c language
Functions in c language
tanmaymodi4
 
Abstract Data Types
Abstract Data Types
karthikeyanC40
 
Python recursion
Python recursion
Prof. Dr. K. Adisesha
 
Automata theory
Automata theory
Pardeep Vats
 
Assembler
Assembler
manpreetgrewal
 
Recursion
Recursion
Abdur Rehman
 
stack & queue
stack & queue
manju rani
 
Hashing Technique In Data Structures
Hashing Technique In Data Structures
SHAKOOR AB
 
Stack and Queue
Stack and Queue
Apurbo Datta
 

Similar to Recursion - Algorithms and Data Structures (20)

Recursive Algorithms with their types and implementation
Recursive Algorithms with their types and implementation
Ahmad177077
 
Recursion.ppt
Recursion.ppt
TalhaHussain58
 
lecture4-recursion.pptx
lecture4-recursion.pptx
Lizhen Shi
 
Recursion vs. Iteration: Code Efficiency & Structure
Recursion vs. Iteration: Code Efficiency & Structure
cogaxor346
 
[系列活動] Machine Learning 機器學習課程
[系列活動] Machine Learning 機器學習課程
台灣資料科學年會
 
DAA UNIT 3
DAA UNIT 3
Dr. SURBHI SAROHA
 
FUNDAMETAL ALG.ppt
FUNDAMETAL ALG.ppt
Menaka Sivakumar
 
DS & Algo 2 - Recursion
DS & Algo 2 - Recursion
Mohammad Imam Hossain
 
Chap14
Chap14
Terry Yoast
 
Python recursion
Python recursion
ToniyaP1
 
The Ultimate Dynamic Programming RoadMap | Tutort Academy
The Ultimate Dynamic Programming RoadMap | Tutort Academy
Tutort Academy
 
ESINF01-Recursion.pdfESINF01-Recursion.pdf
ESINF01-Recursion.pdfESINF01-Recursion.pdf
LusArajo20
 
Python faster for loop
Python faster for loop
💾 Radek Fabisiak
 
nebnznsnshsjsjsjsjsjssjsjsjsjsjsjsjdjw 2.pptx
nebnznsnshsjsjsjsjsjssjsjsjsjsjsjsjdjw 2.pptx
Akash1d
 
Most Asked Coding Questions .pdf
Most Asked Coding Questions .pdf
krishna415649
 
algo_vc_lecture8.ppt
algo_vc_lecture8.ppt
Nehagupta259541
 
Python Programming unit5 (1).pdf
Python Programming unit5 (1).pdf
jamvantsolanki
 
Recursion CBSE Class 12
Recursion CBSE Class 12
chinthala Vijaya Kumar
 
Algorithm chapter 1
Algorithm chapter 1
chidabdu
 
Recursion
Recursion
Jesmin Akhter
 
Recursive Algorithms with their types and implementation
Recursive Algorithms with their types and implementation
Ahmad177077
 
lecture4-recursion.pptx
lecture4-recursion.pptx
Lizhen Shi
 
Recursion vs. Iteration: Code Efficiency & Structure
Recursion vs. Iteration: Code Efficiency & Structure
cogaxor346
 
[系列活動] Machine Learning 機器學習課程
[系列活動] Machine Learning 機器學習課程
台灣資料科學年會
 
Python recursion
Python recursion
ToniyaP1
 
The Ultimate Dynamic Programming RoadMap | Tutort Academy
The Ultimate Dynamic Programming RoadMap | Tutort Academy
Tutort Academy
 
ESINF01-Recursion.pdfESINF01-Recursion.pdf
ESINF01-Recursion.pdfESINF01-Recursion.pdf
LusArajo20
 
nebnznsnshsjsjsjsjsjssjsjsjsjsjsjsjdjw 2.pptx
nebnznsnshsjsjsjsjsjssjsjsjsjsjsjsjdjw 2.pptx
Akash1d
 
Most Asked Coding Questions .pdf
Most Asked Coding Questions .pdf
krishna415649
 
Python Programming unit5 (1).pdf
Python Programming unit5 (1).pdf
jamvantsolanki
 
Algorithm chapter 1
Algorithm chapter 1
chidabdu
 
Ad

More from Priyanka Rana (19)

Insertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority Queues
Priyanka Rana
 
Scrum values
Scrum values
Priyanka Rana
 
Usability testing
Usability testing
Priyanka Rana
 
Content package - Mobile computing
Content package - Mobile computing
Priyanka Rana
 
Scrum retrospective
Scrum retrospective
Priyanka Rana
 
Convergent divergent thinking & wireframeprototyping
Convergent divergent thinking & wireframeprototyping
Priyanka Rana
 
Sketching&storyboarding
Sketching&storyboarding
Priyanka Rana
 
Building better prototype
Building better prototype
Priyanka Rana
 
Mobile presence & location based marketing
Mobile presence & location based marketing
Priyanka Rana
 
User friendliness of website
User friendliness of website
Priyanka Rana
 
E-commerce Marketing & advertising
E-commerce Marketing & advertising
Priyanka Rana
 
E commerce business proposal
E commerce business proposal
Priyanka Rana
 
E-strategic Management-1
E-strategic Management-1
Priyanka Rana
 
Maps&hash tables
Maps&hash tables
Priyanka Rana
 
Heaps & Adaptable priority Queues
Heaps & Adaptable priority Queues
Priyanka Rana
 
Priority queues
Priority queues
Priyanka Rana
 
Trees - Non Linear Data Structure
Trees - Non Linear Data Structure
Priyanka Rana
 
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Priyanka Rana
 
Linked list
Linked list
Priyanka Rana
 
Insertion & Selection Sort - using Priority Queues
Insertion & Selection Sort - using Priority Queues
Priyanka Rana
 
Content package - Mobile computing
Content package - Mobile computing
Priyanka Rana
 
Scrum retrospective
Scrum retrospective
Priyanka Rana
 
Convergent divergent thinking & wireframeprototyping
Convergent divergent thinking & wireframeprototyping
Priyanka Rana
 
Sketching&storyboarding
Sketching&storyboarding
Priyanka Rana
 
Building better prototype
Building better prototype
Priyanka Rana
 
Mobile presence & location based marketing
Mobile presence & location based marketing
Priyanka Rana
 
User friendliness of website
User friendliness of website
Priyanka Rana
 
E-commerce Marketing & advertising
E-commerce Marketing & advertising
Priyanka Rana
 
E commerce business proposal
E commerce business proposal
Priyanka Rana
 
E-strategic Management-1
E-strategic Management-1
Priyanka Rana
 
Heaps & Adaptable priority Queues
Heaps & Adaptable priority Queues
Priyanka Rana
 
Trees - Non Linear Data Structure
Trees - Non Linear Data Structure
Priyanka Rana
 
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Algorithm analysis basics - Seven Functions/Big-Oh/Omega/Theta
Priyanka Rana
 
Ad

Recently uploaded (20)

You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 
You are not excused! How to avoid security blind spots on the way to production
You are not excused! How to avoid security blind spots on the way to production
Michele Leroux Bustamante
 
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Wenn alles versagt - IBM Tape schützt, was zählt! Und besonders mit dem neust...
Josef Weingand
 
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
War_And_Cyber_3_Years_Of_Struggle_And_Lessons_For_Global_Security.pdf
biswajitbanerjee38
 
AI vs Human Writing: Can You Tell the Difference?
AI vs Human Writing: Can You Tell the Difference?
Shashi Sathyanarayana, Ph.D
 
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Using the SQLExecutor for Data Quality Management: aka One man's love for the...
Safe Software
 
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Coordinated Disclosure for ML - What's Different and What's the Same.pdf
Priyanka Aash
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
"Database isolation: how we deal with hundreds of direct connections to the d...
"Database isolation: how we deal with hundreds of direct connections to the d...
Fwdays
 
Curietech AI in action - Accelerate MuleSoft development
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
OWASP Barcelona 2025 Threat Model Library
OWASP Barcelona 2025 Threat Model Library
PetraVukmirovic
 
The Future of AI Agent Development Trends to Watch.pptx
The Future of AI Agent Development Trends to Watch.pptx
Lisa ward
 
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
"How to survive Black Friday: preparing e-commerce for a peak season", Yurii ...
Fwdays
 
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik - Passionate Tech Enthusiast
Raman Bhaumik
 
PyCon SG 25 - Firecracker Made Easy with Python.pdf
PyCon SG 25 - Firecracker Made Easy with Python.pdf
Muhammad Yuga Nugraha
 
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC and Open Hackathons Monthly Highlights June 2025
OpenACC
 
2025_06_18 - OpenMetadata Community Meeting.pdf
2025_06_18 - OpenMetadata Community Meeting.pdf
OpenMetadata
 
Cyber Defense Matrix Workshop - RSA Conference
Cyber Defense Matrix Workshop - RSA Conference
Priyanka Aash
 
Security Tips for Enterprise Azure Solutions
Security Tips for Enterprise Azure Solutions
Michele Leroux Bustamante
 
cnc-processing-centers-centateq-p-110-en.pdf
cnc-processing-centers-centateq-p-110-en.pdf
AmirStern2
 
Techniques for Automatic Device Identification and Network Assignment.pdf
Techniques for Automatic Device Identification and Network Assignment.pdf
Priyanka Aash
 

Recursion - Algorithms and Data Structures

Editor's Notes

  • #2: <number>
  • #4: Russian matryoshka doll Droste effect Barnsley fern <number>
  • #5: Show students that why we need a recursive function. <number>
  • #9: <number>