SlideShare a Scribd company logo
What is Recursion?
The function that calls itself is called as recursive
function and the technique is known as recursion.
Example-: int sample()
{
sample(); //recursion
}
int main()
{
printf(“Start”);
main();
printf(“End”);
}
Stack Memory
main()
printf(“Start”);
main();
main()
printf(“Start”);
main();
main()
printf(“Start”);
main();
main()
printf(“Start”);
main();
Execution
Terminated
Factorial using
Recursion
Stack Memory
if(3==0)
X
else
res=3*fact(2);
return res;
fact(n==3)
if(2==0)
X
else
res=2*fact(1);
return res;
fact(n==2)
if(1==0)
X
else
res=1*fact(0);
return res;
fact(n==1)
if(0==0)
res=1
return res;
fact(n==0)
n=3,res;
fact(3);
Output:6
main()
1
12
6

More Related Content

What's hot (17)

PDF
Monitoramento ambiental e alertas visuais com Zabbix - 3º Zabbix Meetup do In...
Zabbix BR
 
PDF
Singly Linked List
Er. Ganesh Ram Suwal
 
PDF
Javascript: The Important Bits
Zumba Fitness - Technology Team
 
PPT
Operator Overloading
Mani Singh
 
PDF
Debugging TV Frame 0x09
Dmitry Vostokov
 
PDF
C++の話(本当にあった怖い話)
Yuki Tamura
 
PDF
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
akaptur
 
PPTX
Os Practical Assignment 1
Emmanuel Garcia
 
PPT
为什么 rust-lang 吸引我?
勇浩 赖
 
PDF
Advanced QUnit - Front-End JavaScript Unit Testing
Lars Thorup
 
PDF
The Power of CSS
Aniket Pant
 
PDF
Rich and Snappy Apps (No Scaling Required)
Thomas Fuchs
 
PPTX
Reverse Engineering: C++ "for" operator
erithion
 
PPTX
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
zakiakhmad
 
PDF
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays
 
KEY
20110424 action scriptを使わないflash勉強会
Hiroki Mizuno
 
PPTX
Load-time Hacking using LD_PRELOAD
Dharmalingam Ganesan
 
Monitoramento ambiental e alertas visuais com Zabbix - 3º Zabbix Meetup do In...
Zabbix BR
 
Singly Linked List
Er. Ganesh Ram Suwal
 
Javascript: The Important Bits
Zumba Fitness - Technology Team
 
Operator Overloading
Mani Singh
 
Debugging TV Frame 0x09
Dmitry Vostokov
 
C++の話(本当にあった怖い話)
Yuki Tamura
 
Byterun, a Python bytecode interpreter - Allison Kaptur at NYCPython
akaptur
 
Os Practical Assignment 1
Emmanuel Garcia
 
为什么 rust-lang 吸引我?
勇浩 赖
 
Advanced QUnit - Front-End JavaScript Unit Testing
Lars Thorup
 
The Power of CSS
Aniket Pant
 
Rich and Snappy Apps (No Scaling Required)
Thomas Fuchs
 
Reverse Engineering: C++ "for" operator
erithion
 
Exploit Development: EzServer Buffer Overflow oleh Tom Gregory
zakiakhmad
 
FrontDays #3. Иван Федяев, Эволюция JavaScript. Обзор нововведений ECMAScript 6
FrontDays
 
20110424 action scriptを使わないflash勉強会
Hiroki Mizuno
 
Load-time Hacking using LD_PRELOAD
Dharmalingam Ganesan
 

More from AnuragSrivastava272 (13)

PPTX
What is Do while loop?
AnuragSrivastava272
 
PPTX
What is while loop?
AnuragSrivastava272
 
PPTX
What is loops? What is For loop?
AnuragSrivastava272
 
PPTX
What is Switch Case?
AnuragSrivastava272
 
PPTX
What are conditional statements?
AnuragSrivastava272
 
PPTX
What are operators?
AnuragSrivastava272
 
PPTX
What is Non-primitive data type?
AnuragSrivastava272
 
PPTX
What is Data Types and Functions?
AnuragSrivastava272
 
PPTX
What is Variables and Header files
AnuragSrivastava272
 
PPTX
What is IDE?
AnuragSrivastava272
 
PPTX
What is Platform Dependency?
AnuragSrivastava272
 
PPTX
What is Computer Language?
AnuragSrivastava272
 
PPTX
What is Language?
AnuragSrivastava272
 
What is Do while loop?
AnuragSrivastava272
 
What is while loop?
AnuragSrivastava272
 
What is loops? What is For loop?
AnuragSrivastava272
 
What is Switch Case?
AnuragSrivastava272
 
What are conditional statements?
AnuragSrivastava272
 
What are operators?
AnuragSrivastava272
 
What is Non-primitive data type?
AnuragSrivastava272
 
What is Data Types and Functions?
AnuragSrivastava272
 
What is Variables and Header files
AnuragSrivastava272
 
What is IDE?
AnuragSrivastava272
 
What is Platform Dependency?
AnuragSrivastava272
 
What is Computer Language?
AnuragSrivastava272
 
What is Language?
AnuragSrivastava272
 
Ad

Recently uploaded (20)

PPTX
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PPTX
How to Set Maximum Difference Odoo 18 POS
Celine George
 
PDF
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
PDF
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
PPTX
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PPTX
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PPTX
PPT on the Development of Education in the Victorian England
Beena E S
 
PDF
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PDF
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
PPTX
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
PPTX
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
Mathematics 5 - Time Measurement: Time Zone
menchreo
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
How to Set Maximum Difference Odoo 18 POS
Celine George
 
CEREBRAL PALSY: NURSING MANAGEMENT .pdf
PRADEEP ABOTHU
 
Zoology (Animal Physiology) practical Manual
raviralanaresh2
 
Growth and development and milestones, factors
BHUVANESHWARI BADIGER
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
A PPT on Alfred Lord Tennyson's Ulysses.
Beena E S
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PATIENT ASSIGNMENTS AND NURSING CARE RESPONSIBILITIES.pptx
PRADEEP ABOTHU
 
community health nursing question paper 2.pdf
Prince kumar
 
PPT on the Development of Education in the Victorian England
Beena E S
 
The Constitution Review Committee (CRC) has released an updated schedule for ...
nservice241
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
IMP NAAC-Reforms-Stakeholder-Consultation-Presentation-on-Draft-Metrics-Unive...
BHARTIWADEKAR
 
Views on Education of Indian Thinkers J.Krishnamurthy..pptx
ShrutiMahanta1
 
Views on Education of Indian Thinkers Mahatma Gandhi.pptx
ShrutiMahanta1
 
Ad

What is recursion?