SlideShare a Scribd company logo
Recursion
Visit: tshahab.blogspot.com
Recursion
 Basic problem solving technique is to divide a
problem into smaller subproblems
 These subproblems may also be divided into
smaller subproblems
 When the subproblems are small enough to
solve directly the process stops
 A recursive algorithm is a problem solution that
has been expressed in terms of two or more
easier to solve subproblems
What is recursion?
 A procedure that is defined in terms of
itself
 In a computer language a function that
calls itself
Recursion
Recursion
A recursive definition is one which is defined in terms of itself.
Examples:
• A phrase is a "palindrome" if the 1st and last letters are the same,
and what's inside is itself a palindrome (or empty or a single letter)
• Rotor
• Rotator
• 12344321
N =
1 is a natural number
if n is a natural number, then n+1 is a natural number
• The definition of the natural numbers:
Recursion
Recursion
1. Recursive data structure: A data structure that is partially
composed of smaller or simpler instances of the same data
structure. For instance, a tree is composed of smaller trees
(subtrees) and leaf nodes, and a list may have other lists as
elements.
a data structure may contain a pointer to a variable of the same
type:
struct Node {
int data;
Node *next;
};
2. Recursive procedure: a procedure that invokes itself
3. Recursive definitions: if A and B are postfix expressions, then A
B + is a postfix expression.
Recursion in Computer Science
Recursion in Computer Science
Recursive Data Structures
Recursive Data Structures
Linked lists and trees are recursive data structures:
struct Node {
int data;
Node *next;
};
struct TreeNode {
int data;
TreeNode *left;
TreeNode * right;
};
Recursive data structures suggest recursive algorithms.

More Related Content

Similar to Lec-32 What is recursion? A mathematical look (20)

PPT
Database structure Structures Link list and trees and Recurison complete
Adnan abid
 
PPT
Lecture9 recursion
Muhammad Zubair
 
PPT
Cis068 08
FALLEE31188
 
PDF
Introduction to Algorithms And DataStructure
Prasanna996462
 
PPTX
recursion, syntax, types, example program
letheyabala
 
PPTX
4. Recursion - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
PPT
Data Structures- Part5 recursion
Abdullah Al-hazmy
 
PPT
Data structures &algorithms
Nur Saleha
 
PPT
Recursion
Malainine Zaid
 
PDF
Recursion For the Rest of Us (CS Fundamentals Series)
Haseeb Qureshi
 
PPTX
RECURSION.pptx
PrestonKhumbula1
 
PPTX
Types Of Recursion in C++, Data Stuctures by DHEERAJ KATARIA
Dheeraj Kataria
 
PPTX
Recursion is used in programming languages to use a procedure multiple times ...
najiyanasrink
 
PPT
Recursion - Algorithms and Data Structures
Priyanka Rana
 
PPTX
8. Recursion.pptx
Abid523408
 
PDF
Week11
hccit
 
PDF
Lesson 6 recursion
MLG College of Learning, Inc
 
PDF
Module 01 Stack and Recursion
Tushar B Kute
 
PPTX
Recursive Algorithm Detailed Explanation
Prapti Bhattacharjee
 
PPT
Recursion.ppt
ssuser53af97
 
Database structure Structures Link list and trees and Recurison complete
Adnan abid
 
Lecture9 recursion
Muhammad Zubair
 
Cis068 08
FALLEE31188
 
Introduction to Algorithms And DataStructure
Prasanna996462
 
recursion, syntax, types, example program
letheyabala
 
4. Recursion - Data Structures using C++ by Varsha Patil
widespreadpromotion
 
Data Structures- Part5 recursion
Abdullah Al-hazmy
 
Data structures &algorithms
Nur Saleha
 
Recursion
Malainine Zaid
 
Recursion For the Rest of Us (CS Fundamentals Series)
Haseeb Qureshi
 
RECURSION.pptx
PrestonKhumbula1
 
Types Of Recursion in C++, Data Stuctures by DHEERAJ KATARIA
Dheeraj Kataria
 
Recursion is used in programming languages to use a procedure multiple times ...
najiyanasrink
 
Recursion - Algorithms and Data Structures
Priyanka Rana
 
8. Recursion.pptx
Abid523408
 
Week11
hccit
 
Lesson 6 recursion
MLG College of Learning, Inc
 
Module 01 Stack and Recursion
Tushar B Kute
 
Recursive Algorithm Detailed Explanation
Prapti Bhattacharjee
 
Recursion.ppt
ssuser53af97
 

More from Anil Yadav (20)

PPTX
Link List : Introduction to List and Linked Lists
Anil Yadav
 
PPTX
Link List REPRESENTATION OF DOUBLY LINKED LIST
Anil Yadav
 
PPTX
ALGORITHM FOR PUSHING AN ELEMENT TO A QUEUE
Anil Yadav
 
PPTX
Link List STACK and Queue USING LINKED LIST
Anil Yadav
 
PPTX
Link List Programming Linked List in Cpp
Anil Yadav
 
PPTX
Link List & ALGORITHM FOR DELETING A NODE
Anil Yadav
 
PPTX
Link List ALGORITHM FOR INSERTING A NODE
Anil Yadav
 
PPTX
Presentations Linked Lists Data Structure
Anil Yadav
 
PPT
Lec-12, 13 Quees First In First Out (FIFO)
Anil Yadav
 
PPT
Lec-12, 13 Quee s Applications of Queues
Anil Yadav
 
PPT
Lec-12, 13 Quees Array Implementation IN
Anil Yadav
 
PPT
Lec-12, 13 Quees In Queue IntQueue(int s)
Anil Yadav
 
PPT
Lec-12, 13 Quees A class for Dynamic Queue implementation
Anil Yadav
 
PPT
Function enqueue inserts the value in num
Anil Yadav
 
PPT
Lec-12, 13 Quees -How to determine empty and full Queues?
Anil Yadav
 
PDF
Unit2-BIS Business Information system Data
Anil Yadav
 
PPT
Lec-12, 13 Queues - IntQueue IntQueue(int s) //constructor
Anil Yadav
 
PPT
Lec-12, 13 Quees Another implementation of Queues using Arrays
Anil Yadav
 
PPT
Lec-12, 13 Quees - Circular Queues and Implementation with Array
Anil Yadav
 
PPT
Lec-32 Recursion - Divide and Conquer in Queue
Anil Yadav
 
Link List : Introduction to List and Linked Lists
Anil Yadav
 
Link List REPRESENTATION OF DOUBLY LINKED LIST
Anil Yadav
 
ALGORITHM FOR PUSHING AN ELEMENT TO A QUEUE
Anil Yadav
 
Link List STACK and Queue USING LINKED LIST
Anil Yadav
 
Link List Programming Linked List in Cpp
Anil Yadav
 
Link List & ALGORITHM FOR DELETING A NODE
Anil Yadav
 
Link List ALGORITHM FOR INSERTING A NODE
Anil Yadav
 
Presentations Linked Lists Data Structure
Anil Yadav
 
Lec-12, 13 Quees First In First Out (FIFO)
Anil Yadav
 
Lec-12, 13 Quee s Applications of Queues
Anil Yadav
 
Lec-12, 13 Quees Array Implementation IN
Anil Yadav
 
Lec-12, 13 Quees In Queue IntQueue(int s)
Anil Yadav
 
Lec-12, 13 Quees A class for Dynamic Queue implementation
Anil Yadav
 
Function enqueue inserts the value in num
Anil Yadav
 
Lec-12, 13 Quees -How to determine empty and full Queues?
Anil Yadav
 
Unit2-BIS Business Information system Data
Anil Yadav
 
Lec-12, 13 Queues - IntQueue IntQueue(int s) //constructor
Anil Yadav
 
Lec-12, 13 Quees Another implementation of Queues using Arrays
Anil Yadav
 
Lec-12, 13 Quees - Circular Queues and Implementation with Array
Anil Yadav
 
Lec-32 Recursion - Divide and Conquer in Queue
Anil Yadav
 
Ad

Recently uploaded (20)

PDF
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
PPTX
YSPH VMOC Special Report - Measles Outbreak Southwest US 7-20-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
PPTX
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTX
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
PPTX
Introduction to Probability(basic) .pptx
purohitanuj034
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
Virus sequence retrieval from NCBI database
yamunaK13
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
Unlock the Power of Cursor AI: MuleSoft Integrations
Veera Pallapu
 
PPTX
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
DOCX
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
PPTX
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
PPTX
Digital Professionalism and Interpersonal Competence
rutvikgediya1
 
PPTX
Electrophysiology_of_Heart. Electrophysiology studies in Cardiovascular syste...
Rajshri Ghogare
 
PPTX
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
DOCX
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
PPTX
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
PPTX
The Future of Artificial Intelligence Opportunities and Risks Ahead
vaghelajayendra784
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
YSPH VMOC Special Report - Measles Outbreak Southwest US 7-20-2025.pptx
Yale School of Public Health - The Virtual Medical Operations Center (VMOC)
 
Sonnet 130_ My Mistress’ Eyes Are Nothing Like the Sun By William Shakespear...
DhatriParmar
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
Introduction to Probability(basic) .pptx
purohitanuj034
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
Virus sequence retrieval from NCBI database
yamunaK13
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
Unlock the Power of Cursor AI: MuleSoft Integrations
Veera Pallapu
 
HEALTH CARE DELIVERY SYSTEM - UNIT 2 - GNM 3RD YEAR.pptx
Priyanshu Anand
 
Unit 5: Speech-language and swallowing disorders
JELLA VISHNU DURGA PRASAD
 
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
Digital Professionalism and Interpersonal Competence
rutvikgediya1
 
Electrophysiology_of_Heart. Electrophysiology studies in Cardiovascular syste...
Rajshri Ghogare
 
How to Track Skills & Contracts Using Odoo 18 Employee
Celine George
 
pgdei-UNIT -V Neurological Disorders & developmental disabilities
JELLA VISHNU DURGA PRASAD
 
20250924 Navigating the Future: How to tell the difference between an emergen...
McGuinness Institute
 
The Future of Artificial Intelligence Opportunities and Risks Ahead
vaghelajayendra784
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
Ad

Lec-32 What is recursion? A mathematical look

  • 2. Recursion  Basic problem solving technique is to divide a problem into smaller subproblems  These subproblems may also be divided into smaller subproblems  When the subproblems are small enough to solve directly the process stops  A recursive algorithm is a problem solution that has been expressed in terms of two or more easier to solve subproblems
  • 3. What is recursion?  A procedure that is defined in terms of itself  In a computer language a function that calls itself
  • 4. Recursion Recursion A recursive definition is one which is defined in terms of itself. Examples: • A phrase is a "palindrome" if the 1st and last letters are the same, and what's inside is itself a palindrome (or empty or a single letter) • Rotor • Rotator • 12344321
  • 5. N = 1 is a natural number if n is a natural number, then n+1 is a natural number • The definition of the natural numbers: Recursion Recursion
  • 6. 1. Recursive data structure: A data structure that is partially composed of smaller or simpler instances of the same data structure. For instance, a tree is composed of smaller trees (subtrees) and leaf nodes, and a list may have other lists as elements. a data structure may contain a pointer to a variable of the same type: struct Node { int data; Node *next; }; 2. Recursive procedure: a procedure that invokes itself 3. Recursive definitions: if A and B are postfix expressions, then A B + is a postfix expression. Recursion in Computer Science Recursion in Computer Science
  • 7. Recursive Data Structures Recursive Data Structures Linked lists and trees are recursive data structures: struct Node { int data; Node *next; }; struct TreeNode { int data; TreeNode *left; TreeNode * right; }; Recursive data structures suggest recursive algorithms.

Editor's Notes

  • #1: Visit: tshahab.blogspot.com
  • #4: Visit: tshahab.blogspot.com