SlideShare a Scribd company logo
1 of 19
Recursive Functions ,[object Object],[object Object]
Function Analysis for call  fib(5) fib(5) fib(4) fib(3) fib(3) fib(2) fib(1) fib(0) fib(2) fib(1) fib(0) fib(1) fib(2) fib(1) fib(0) fib(1) public static int  fib( int  n) if  (n == 0 || n == 1) return  n else return  fib(n-1) + fib(n-2) 1 1 1 1 1 0 0 0 1 1 2 1 3 2 5
Recursive Function Calls on the Stack ,[object Object],[object Object],[object Object],[object Object],[object Object]
Anatomy of a Recursive Function ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Finding Recursive Solutions ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Steps Leading to Recursive Solutions ,[object Object],[object Object],[object Object],[object Object]
Designing a recursive solution: Writing a String Backward ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Designing a recursive solution: Writing a String Backward ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Designing a recursive solution: Writing a String Backward ,[object Object],[object Object],[object Object],[object Object],[object Object]
Box trace of  writeBackward(“cat”, 3) The initial call is made, and the method begins execution: s = “cat” size = 3 s = “cat” size = 3 s = “cat” size = 2 s = “cat” size = 1 s = “cat” size = 2 s = “cat” size = 3 A A A Outputline:  ta Point A is reached, and the recursive call is made. The new invocation begins execution: Outputline:  t Point A ( writeBackward(s, size-1))  is reached, and the recursive call is made. The new invocation begins execution:
Box trace of  writeBackward(“cat”, 3) Output line:  tac Point A is reached, and the recursive call is made. The new evocation begins execution: s = “cat” size = 3 s = “cat” size = 2 s = “cat” size = 1 s = “cat” size = 0 s = “cat” size = 0 s = “cat” size = 1 s = “cat” size = 2 s = “cat” size = 3 A A A A A A This is the base case, so this invocation completes. Control returns to the calling box, which continues execution:
Box trace of  writeBackward(“cat”, 3) This invocation completes. Control returns to the calling box, which continues execution: s = “cat” size = 3 s = “cat” size = 2 s = “cat” size = 1 s = “cat” size = 0 s = “cat” size = 0 s = “cat” size = 1 s = “cat” size = 2 s = “cat” size = 3 A A A A A A This invocation completes. Control returns to the calling box, which continues execution: This invocation completes. Control returns to the statement following the initial call.
A recursive definition of factorial  n! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
return 2*fact(1) 2* ? Figure 2.2 fact(3) System.out.println(fact(3)); ? return 3*fact(2) 3*? return 1*fact(0) 1* ? return 1 6 1 1 2
Figure 2.3 A box
Figure 2.4 The beginning of the box trace
Figure 2.5a Box trace of  fact(3)
Figure 2.5b Box trace of  fact(3)
Figure 2.5c Box trace of  fact(3)

More Related Content

What's hot

40+ examples of user defined methods in java with explanation
40+ examples of user defined methods in java with explanation40+ examples of user defined methods in java with explanation
40+ examples of user defined methods in java with explanationHarish Gyanani
 
Assignment week0 c++
Assignment  week0 c++Assignment  week0 c++
Assignment week0 c++Netaji Gandi
 
Recursion for GCE AS Computing
Recursion for GCE AS ComputingRecursion for GCE AS Computing
Recursion for GCE AS Computingpgmckillop
 
Symmetric ciphers questions and answers
Symmetric ciphers questions and answersSymmetric ciphers questions and answers
Symmetric ciphers questions and answersprdpgpt
 
Modern Block Cipher- Modern Symmetric-Key Cipher
Modern Block Cipher- Modern Symmetric-Key CipherModern Block Cipher- Modern Symmetric-Key Cipher
Modern Block Cipher- Modern Symmetric-Key CipherMahbubur Rahman
 
Recursion(Advanced data structure)
Recursion(Advanced data structure)Recursion(Advanced data structure)
Recursion(Advanced data structure)kurubameena1
 
Computer Science Programming Assignment Help
Computer Science Programming Assignment HelpComputer Science Programming Assignment Help
Computer Science Programming Assignment HelpProgramming Homework Help
 
Chapter 9 divide and conquer handouts with notes
Chapter 9   divide and conquer handouts with notesChapter 9   divide and conquer handouts with notes
Chapter 9 divide and conquer handouts with notesmailund
 
Paper on Optimized AES Algorithm Core Using FeedBack Architecture
Paper on Optimized AES Algorithm Core Using  FeedBack Architecture Paper on Optimized AES Algorithm Core Using  FeedBack Architecture
Paper on Optimized AES Algorithm Core Using FeedBack Architecture Dhaval Kaneria
 

What's hot (20)

Rsa encryption
Rsa encryptionRsa encryption
Rsa encryption
 
CPP Homework Help
CPP Homework HelpCPP Homework Help
CPP Homework Help
 
Recursion
RecursionRecursion
Recursion
 
40+ examples of user defined methods in java with explanation
40+ examples of user defined methods in java with explanation40+ examples of user defined methods in java with explanation
40+ examples of user defined methods in java with explanation
 
Assignment week0 c++
Assignment  week0 c++Assignment  week0 c++
Assignment week0 c++
 
Recursion
RecursionRecursion
Recursion
 
Recursion for GCE AS Computing
Recursion for GCE AS ComputingRecursion for GCE AS Computing
Recursion for GCE AS Computing
 
User Defined Functions in C Language
User Defined Functions   in  C LanguageUser Defined Functions   in  C Language
User Defined Functions in C Language
 
Mid term
Mid termMid term
Mid term
 
Symmetric ciphers questions and answers
Symmetric ciphers questions and answersSymmetric ciphers questions and answers
Symmetric ciphers questions and answers
 
Fibonacci using matlab
Fibonacci using matlabFibonacci using matlab
Fibonacci using matlab
 
Modern Block Cipher- Modern Symmetric-Key Cipher
Modern Block Cipher- Modern Symmetric-Key CipherModern Block Cipher- Modern Symmetric-Key Cipher
Modern Block Cipher- Modern Symmetric-Key Cipher
 
Recursion(Advanced data structure)
Recursion(Advanced data structure)Recursion(Advanced data structure)
Recursion(Advanced data structure)
 
Vb.net ii
Vb.net iiVb.net ii
Vb.net ii
 
Computer Science Assignment Help
Computer Science Assignment HelpComputer Science Assignment Help
Computer Science Assignment Help
 
Computer Science Programming Assignment Help
Computer Science Programming Assignment HelpComputer Science Programming Assignment Help
Computer Science Programming Assignment Help
 
Chapter 9 divide and conquer handouts with notes
Chapter 9   divide and conquer handouts with notesChapter 9   divide and conquer handouts with notes
Chapter 9 divide and conquer handouts with notes
 
Reconstruction
ReconstructionReconstruction
Reconstruction
 
Paper on Optimized AES Algorithm Core Using FeedBack Architecture
Paper on Optimized AES Algorithm Core Using  FeedBack Architecture Paper on Optimized AES Algorithm Core Using  FeedBack Architecture
Paper on Optimized AES Algorithm Core Using FeedBack Architecture
 
Network security CS6
Network security   CS6Network security   CS6
Network security CS6
 

Viewers also liked

แบบอ้างอิง Osi
แบบอ้างอิง Osiแบบอ้างอิง Osi
แบบอ้างอิง OsiPituk Sense
 
Picasa
PicasaPicasa
Picasanok_bb
 
Biz ideas v5
Biz ideas v5Biz ideas v5
Biz ideas v5iamrgupta
 
Расчет настоящего уровня инфляции
Расчет настоящего уровня инфляцииРасчет настоящего уровня инфляции
Расчет настоящего уровня инфляцииalexeykonkov
 
Inanimate Alice episode 5 by Ian and Henry
Inanimate Alice episode 5 by Ian and Henry Inanimate Alice episode 5 by Ian and Henry
Inanimate Alice episode 5 by Ian and Henry MrsPrentice
 
Supporting Apache Brands While Making A Profit - v2.0b
Supporting Apache Brands While Making A Profit - v2.0bSupporting Apache Brands While Making A Profit - v2.0b
Supporting Apache Brands While Making A Profit - v2.0bShane Curcuru
 
De Wijkonderneming Terugblik En Resultatenoverzicht 2010.
De Wijkonderneming Terugblik En Resultatenoverzicht 2010.De Wijkonderneming Terugblik En Resultatenoverzicht 2010.
De Wijkonderneming Terugblik En Resultatenoverzicht 2010.Mieke Sanden, van der
 
Lugares turisticos del mundo
Lugares turisticos del mundoLugares turisticos del mundo
Lugares turisticos del mundojesellrodriguez
 
English janlokpal (1)
English janlokpal (1)English janlokpal (1)
English janlokpal (1)Mb Narayanan
 
ACC 626 - Forensics for IT
ACC 626 - Forensics for ITACC 626 - Forensics for IT
ACC 626 - Forensics for ITj9lai
 
Angical fest 2011 2º dia
Angical fest 2011 2º diaAngical fest 2011 2º dia
Angical fest 2011 2º diaangical-piaui
 
Win pcap filtering expression syntax
Win pcap  filtering expression syntaxWin pcap  filtering expression syntax
Win pcap filtering expression syntaxVota Ppt
 

Viewers also liked (20)

แบบอ้างอิง Osi
แบบอ้างอิง Osiแบบอ้างอิง Osi
แบบอ้างอิง Osi
 
Picasa
PicasaPicasa
Picasa
 
Biz ideas v5
Biz ideas v5Biz ideas v5
Biz ideas v5
 
Расчет настоящего уровня инфляции
Расчет настоящего уровня инфляцииРасчет настоящего уровня инфляции
Расчет настоящего уровня инфляции
 
Inanimate Alice episode 5 by Ian and Henry
Inanimate Alice episode 5 by Ian and Henry Inanimate Alice episode 5 by Ian and Henry
Inanimate Alice episode 5 by Ian and Henry
 
Supporting Apache Brands While Making A Profit - v2.0b
Supporting Apache Brands While Making A Profit - v2.0bSupporting Apache Brands While Making A Profit - v2.0b
Supporting Apache Brands While Making A Profit - v2.0b
 
Islamic Religion
Islamic  ReligionIslamic  Religion
Islamic Religion
 
De Wijkonderneming Terugblik En Resultatenoverzicht 2010.
De Wijkonderneming Terugblik En Resultatenoverzicht 2010.De Wijkonderneming Terugblik En Resultatenoverzicht 2010.
De Wijkonderneming Terugblik En Resultatenoverzicht 2010.
 
Bio outsource hcp
Bio outsource hcpBio outsource hcp
Bio outsource hcp
 
Lugares turisticos del mundo
Lugares turisticos del mundoLugares turisticos del mundo
Lugares turisticos del mundo
 
English janlokpal (1)
English janlokpal (1)English janlokpal (1)
English janlokpal (1)
 
Chapter5
Chapter5Chapter5
Chapter5
 
Gerbang Logika
Gerbang LogikaGerbang Logika
Gerbang Logika
 
Test
TestTest
Test
 
Materi Dasar PHP
Materi Dasar PHPMateri Dasar PHP
Materi Dasar PHP
 
Pagenotes
PagenotesPagenotes
Pagenotes
 
ACC 626 - Forensics for IT
ACC 626 - Forensics for ITACC 626 - Forensics for IT
ACC 626 - Forensics for IT
 
Angical fest 2011 2º dia
Angical fest 2011 2º diaAngical fest 2011 2º dia
Angical fest 2011 2º dia
 
Win pcap filtering expression syntax
Win pcap  filtering expression syntaxWin pcap  filtering expression syntax
Win pcap filtering expression syntax
 
Calendario 2012
Calendario 2012Calendario 2012
Calendario 2012
 

Similar to 5 2

Sample Exam Questions on Python for revision
Sample Exam Questions on Python for revisionSample Exam Questions on Python for revision
Sample Exam Questions on Python for revisionafsheenfaiq2
 
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdfUnit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdfyashodamb
 
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
Task4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docxTask4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docx
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docxjosies1
 
35000120060_Nitesh Modi_CSE Presentation on recursion.pptx
35000120060_Nitesh Modi_CSE Presentation on recursion.pptx35000120060_Nitesh Modi_CSE Presentation on recursion.pptx
35000120060_Nitesh Modi_CSE Presentation on recursion.pptx15AnasKhan
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting classgiridaroori
 
Matrix Multiplication(An example of concurrent programming)
Matrix Multiplication(An example of concurrent programming)Matrix Multiplication(An example of concurrent programming)
Matrix Multiplication(An example of concurrent programming)Pramit Kumar
 
NPTEL QUIZ.docx
NPTEL QUIZ.docxNPTEL QUIZ.docx
NPTEL QUIZ.docxGEETHAR59
 
Hive function-cheat-sheet
Hive function-cheat-sheetHive function-cheat-sheet
Hive function-cheat-sheetDr. Volkan OBAN
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptxPython Homework Help
 
Recursion vs. Iteration: Code Efficiency & Structure
Recursion vs. Iteration: Code Efficiency & StructureRecursion vs. Iteration: Code Efficiency & Structure
Recursion vs. Iteration: Code Efficiency & Structurecogaxor346
 
Unit-I Recursion.pptx
Unit-I Recursion.pptxUnit-I Recursion.pptx
Unit-I Recursion.pptxajajkhan16
 
lecture4-recursion.pptx
lecture4-recursion.pptxlecture4-recursion.pptx
lecture4-recursion.pptxLizhen Shi
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentationManchireddy Reddy
 
Sure interview algorithm-1103
Sure interview algorithm-1103Sure interview algorithm-1103
Sure interview algorithm-1103Sure Interview
 

Similar to 5 2 (20)

algo_vc_lecture8.ppt
algo_vc_lecture8.pptalgo_vc_lecture8.ppt
algo_vc_lecture8.ppt
 
Sample Exam Questions on Python for revision
Sample Exam Questions on Python for revisionSample Exam Questions on Python for revision
Sample Exam Questions on Python for revision
 
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdfUnit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
Unit-3 greedy method, Prim's algorithm, Kruskal's algorithm.pdf
 
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
Task4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docxTask4output.txt 2  5  9 13 15 10  1  0  3  7 11 14 1.docx
Task4output.txt 2 5 9 13 15 10 1 0 3 7 11 14 1.docx
 
Recursion.pdf
Recursion.pdfRecursion.pdf
Recursion.pdf
 
35000120060_Nitesh Modi_CSE Presentation on recursion.pptx
35000120060_Nitesh Modi_CSE Presentation on recursion.pptx35000120060_Nitesh Modi_CSE Presentation on recursion.pptx
35000120060_Nitesh Modi_CSE Presentation on recursion.pptx
 
dynamic programming Rod cutting class
dynamic programming Rod cutting classdynamic programming Rod cutting class
dynamic programming Rod cutting class
 
Matrix Multiplication(An example of concurrent programming)
Matrix Multiplication(An example of concurrent programming)Matrix Multiplication(An example of concurrent programming)
Matrix Multiplication(An example of concurrent programming)
 
NPTEL QUIZ.docx
NPTEL QUIZ.docxNPTEL QUIZ.docx
NPTEL QUIZ.docx
 
Recursion.ppt
 Recursion.ppt Recursion.ppt
Recursion.ppt
 
Hive function-cheat-sheet
Hive function-cheat-sheetHive function-cheat-sheet
Hive function-cheat-sheet
 
Introduction to Python Programming.pptx
Introduction to Python Programming.pptxIntroduction to Python Programming.pptx
Introduction to Python Programming.pptx
 
Recursion vs. Iteration: Code Efficiency & Structure
Recursion vs. Iteration: Code Efficiency & StructureRecursion vs. Iteration: Code Efficiency & Structure
Recursion vs. Iteration: Code Efficiency & Structure
 
Unit-I Recursion.pptx
Unit-I Recursion.pptxUnit-I Recursion.pptx
Unit-I Recursion.pptx
 
1.2 matlab numerical data
1.2  matlab numerical data1.2  matlab numerical data
1.2 matlab numerical data
 
lecture4-recursion.pptx
lecture4-recursion.pptxlecture4-recursion.pptx
lecture4-recursion.pptx
 
Tower of Hanoi.ppt
Tower of Hanoi.pptTower of Hanoi.ppt
Tower of Hanoi.ppt
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
Sure interview algorithm-1103
Sure interview algorithm-1103Sure interview algorithm-1103
Sure interview algorithm-1103
 
6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx6-Python-Recursion PPT.pptx
6-Python-Recursion PPT.pptx
 

More from FALLEE31188 (20)

Lecture4
Lecture4Lecture4
Lecture4
 
Lecture2
Lecture2Lecture2
Lecture2
 
L16
L16L16
L16
 
L2
L2L2
L2
 
Inheritance
InheritanceInheritance
Inheritance
 
Inheritance
InheritanceInheritance
Inheritance
 
Functions
FunctionsFunctions
Functions
 
Field name
Field nameField name
Field name
 
Encapsulation
EncapsulationEncapsulation
Encapsulation
 
Cpp tutorial
Cpp tutorialCpp tutorial
Cpp tutorial
 
Cis068 08
Cis068 08Cis068 08
Cis068 08
 
Chapter14
Chapter14Chapter14
Chapter14
 
Chapt03
Chapt03Chapt03
Chapt03
 
C++lecture9
C++lecture9C++lecture9
C++lecture9
 
C++ polymorphism
C++ polymorphismC++ polymorphism
C++ polymorphism
 
C++ classes tutorials
C++ classes tutorialsC++ classes tutorials
C++ classes tutorials
 
C1320prespost
C1320prespostC1320prespost
C1320prespost
 
Brookshear 06
Brookshear 06Brookshear 06
Brookshear 06
 
Book ppt
Book pptBook ppt
Book ppt
 
Assignment 2
Assignment 2Assignment 2
Assignment 2
 

Recently uploaded

REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfSherif Taha
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.MaryamAhmad92
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSCeline George
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfDr Vijay Vishwakarma
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 

Recently uploaded (20)

REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
How to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POSHow to Manage Global Discount in Odoo 17 POS
How to Manage Global Discount in Odoo 17 POS
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdfUnit 3 Emotional Intelligence and Spiritual Intelligence.pdf
Unit 3 Emotional Intelligence and Spiritual Intelligence.pdf
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 

5 2

  • 1.
  • 2. Function Analysis for call fib(5) fib(5) fib(4) fib(3) fib(3) fib(2) fib(1) fib(0) fib(2) fib(1) fib(0) fib(1) fib(2) fib(1) fib(0) fib(1) public static int fib( int n) if (n == 0 || n == 1) return n else return fib(n-1) + fib(n-2) 1 1 1 1 1 0 0 0 1 1 2 1 3 2 5
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. Box trace of writeBackward(“cat”, 3) The initial call is made, and the method begins execution: s = “cat” size = 3 s = “cat” size = 3 s = “cat” size = 2 s = “cat” size = 1 s = “cat” size = 2 s = “cat” size = 3 A A A Outputline: ta Point A is reached, and the recursive call is made. The new invocation begins execution: Outputline: t Point A ( writeBackward(s, size-1)) is reached, and the recursive call is made. The new invocation begins execution:
  • 11. Box trace of writeBackward(“cat”, 3) Output line: tac Point A is reached, and the recursive call is made. The new evocation begins execution: s = “cat” size = 3 s = “cat” size = 2 s = “cat” size = 1 s = “cat” size = 0 s = “cat” size = 0 s = “cat” size = 1 s = “cat” size = 2 s = “cat” size = 3 A A A A A A This is the base case, so this invocation completes. Control returns to the calling box, which continues execution:
  • 12. Box trace of writeBackward(“cat”, 3) This invocation completes. Control returns to the calling box, which continues execution: s = “cat” size = 3 s = “cat” size = 2 s = “cat” size = 1 s = “cat” size = 0 s = “cat” size = 0 s = “cat” size = 1 s = “cat” size = 2 s = “cat” size = 3 A A A A A A This invocation completes. Control returns to the calling box, which continues execution: This invocation completes. Control returns to the statement following the initial call.
  • 13.
  • 14. return 2*fact(1) 2* ? Figure 2.2 fact(3) System.out.println(fact(3)); ? return 3*fact(2) 3*? return 1*fact(0) 1* ? return 1 6 1 1 2
  • 16. Figure 2.4 The beginning of the box trace
  • 17. Figure 2.5a Box trace of fact(3)
  • 18. Figure 2.5b Box trace of fact(3)
  • 19. Figure 2.5c Box trace of fact(3)