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

Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxNikitaBankoti2
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfChris Hunter
 
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
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docxPoojaSen20
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
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)

Role Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptxRole Of Transgenic Animal In Target Validation-1.pptx
Role Of Transgenic Animal In Target Validation-1.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Making and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdfMaking and Justifying Mathematical Decisions.pdf
Making and Justifying Mathematical Decisions.pdf
 
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.
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
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
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
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)