SlideShare una empresa de Scribd logo
1 de 70
 
Chapter 14 Recursion Copyright © 2008 Pearson Addison-Wesley.  All rights reserved.
Overview ,[object Object],[object Object],[object Object],Slide 14-
14.1 Recursive Functions for Tasks Copyright © 2008 Pearson Addison-Wesley.  All rights reserved.
Recursive Functions  for Tasks ,[object Object],[object Object],[object Object],[object Object],[object Object],Slide 14-
Case Study:  Vertical Numbers ,[object Object],[object Object],Slide 14-
Case Study:  Vertical Numbers ,[object Object],[object Object],[object Object],[object Object],[object Object],Slide 14-
Case Study:  Vertical Numbers  (cont.) ,[object Object],[object Object],Slide 14-
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Case Study:  Vertical Numbers  (cont.) Slide 14-  Display 14.1 ( 1 ) Display 14.1 ( 2 )
Tracing a Recursive Call ,[object Object],Slide 14-  Calls write_vertical(12) resume Output 3 Function call ends
Tracing write_vertical(12) ,[object Object],Slide 14-  Calls write_vertical(1) resume Output 2 Function call ends
Tracing write_vertical(1) ,[object Object],Slide 14-  Simplest case is now true Function call ends Output 1
A Closer Look at Recursion ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Slide 14-
How Recursion Ends ,[object Object],[object Object],[object Object],[object Object],[object Object],Slide 14-
"Infinite" Recursion ,[object Object],[object Object],Slide 14-
Example: Infinite Recursion ,[object Object],Slide 14-
Stacks for Recursion ,[object Object],[object Object],[object Object],[object Object],[object Object],Slide 14-
Last-in / First-out ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Slide 14-
Stacks and The Recursive Call ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Slide 14-
The Stack  and Ending Recursive Calls ,[object Object],[object Object],[object Object],[object Object],Slide 14-
Activation Frames ,[object Object],[object Object],[object Object],[object Object],Slide 14-
Stack Overflow ,[object Object],[object Object],[object Object],[object Object],Slide 14-
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Recursion versus Iteration Slide 14-  Display 14.2
Section 14.1 Conclusion ,[object Object],[object Object],[object Object],[object Object],Slide 14-
14.2 Recursive Functions for Values Copyright © 2008 Pearson Addison-Wesley.  All rights reserved.
Recursive Functions  for Values ,[object Object],[object Object],[object Object],[object Object],Slide 14-
[object Object],[object Object],[object Object],[object Object],Program Example: A Powers Function Slide 14-  Display 14.3
[object Object],Tracing power(2,1) Slide 14-  Call to power(2,0) resume 1 return 2 Function Ends
Tracing power(2,0) ,[object Object],Slide 14-  Function call ends 1 is returned
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Tracing power(2, 3) Slide 14-  Display 14.4
Section 14.2 Conclusion ,[object Object],[object Object],Slide 14-
14.3 Thinking Recursively Copyright © 2008 Pearson Addison-Wesley.  All rights reserved.
Thinking Recursively ,[object Object],[object Object],[object Object],[object Object],[object Object],Slide 14-
Reviewing the power function ,[object Object],[object Object],Slide 14-
Review of power (cont.) ,[object Object],[object Object],Slide 14-
Review of power (cont.) ,[object Object],[object Object],Slide 14-
Recursive void-functions ,[object Object],[object Object],[object Object],[object Object],Slide 14-
Case Study: Binary Search ,[object Object],[object Object],[object Object],[object Object],Slide 14-
Binary Search: Problem Definition ,[object Object],[object Object],[object Object],[object Object],Slide 14-
Binary Search Problem Definition (cont.) ,[object Object],Slide 14-
Binary Search Algorithm Design ,[object Object],[object Object],[object Object],[object Object],[object Object],Slide 14-
Binary Search Algorithm Design  (cont.) ,[object Object],[object Object],Slide 14-
Binary Search Algorithm Design (cont.) ,[object Object],[object Object],[object Object],[object Object],Slide 14-
Binary Search Algorithm Design (cont.) ,[object Object],Slide 14-
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],Binary Search Algorithm Design (cont.) Slide 14-  Display 14.5 Display 14.7
[object Object],[object Object],Binary Search Writing the Code Slide 14-  Display 14.6 (1) Display 14.6 (2)
Binary Search Checking the Recursion ,[object Object],[object Object],Slide 14-
Binary Search Checking the Recursion (cont.) ,[object Object],[object Object],[object Object],[object Object],Slide 14-
Binary Search Checking the Recursion (cont.) ,[object Object],[object Object],[object Object],Slide 14-
Binary Search Efficiency ,[object Object],[object Object],[object Object],[object Object],Slide 14-
[object Object],[object Object],[object Object],Binary Search An Iterative Version Slide 14-  Display 14.8
Program Example: A Recursive Member Function ,[object Object],[object Object],[object Object],Slide 14-
[object Object],[object Object],[object Object],[object Object],Class BankAccount Function update Slide 14-  Display 14.9 (1) Display 14.9 (2)
Function update Checking the Recursion ,[object Object],[object Object],[object Object],[object Object],Slide 14-
Function update Checking the Recursion (cont.) ,[object Object],[object Object],Slide 14-
Overloaded Functions ,[object Object],[object Object],[object Object],Slide 14-
Section 14.3 Conclusion ,[object Object],[object Object],Slide 14-
Chapter 14 -- End Slide 14-
Display 14.1 (1/2)   Slide 14-  Back Next
Display 14.1 (2/2) Slide 14-  Back Next
Display 14.2 Slide 14-  Back Next
Display 14.3 Slide 14-  Back Next
Display 14.4 Slide 14-  Next Back
Display 14.5 Slide 14-  Back Next
Display 14.6 (1/2) Slide 14-  Back Next
Display 14.6 (2/2) Slide 14-  Back Next
Display 14.7 Slide 14-  Back Next
Display 14.8 Slide 14-  Next Back
Display 14.9 (1/2) Slide 14-  Back Next
Display 14.9 (2/2) Slide 14-  Back Next

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

Recursion and looping
Recursion and loopingRecursion and looping
Recursion and looping
 
Software Construction Assignment Help
Software Construction Assignment HelpSoftware Construction Assignment Help
Software Construction Assignment Help
 
Computer Science Assignment Help
Computer Science Assignment HelpComputer Science Assignment Help
Computer Science Assignment Help
 
functions
functionsfunctions
functions
 
Iterations and Recursions
Iterations and RecursionsIterations and Recursions
Iterations and Recursions
 
Digital Signal Processing Lab Manual ECE students
Digital Signal Processing Lab Manual ECE studentsDigital Signal Processing Lab Manual ECE students
Digital Signal Processing Lab Manual ECE students
 
DSP Lab Manual (10ECL57) - VTU Syllabus (KSSEM)
DSP Lab Manual (10ECL57) - VTU Syllabus (KSSEM)DSP Lab Manual (10ECL57) - VTU Syllabus (KSSEM)
DSP Lab Manual (10ECL57) - VTU Syllabus (KSSEM)
 
Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report Digital signal Processing all matlab code with Lab report
Digital signal Processing all matlab code with Lab report
 
Computational Assignment Help
Computational Assignment HelpComputational Assignment Help
Computational Assignment Help
 
Iteration, induction, and recursion
Iteration, induction, and recursionIteration, induction, and recursion
Iteration, induction, and recursion
 
4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf4th_Ed_Ch03.pdf
4th_Ed_Ch03.pdf
 
Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)Maharishi University of Management (MSc Computer Science test questions)
Maharishi University of Management (MSc Computer Science test questions)
 
Recursion
RecursionRecursion
Recursion
 
Code optimization
Code optimization Code optimization
Code optimization
 
Introduction to code optimization by dipankar
Introduction to code optimization by dipankarIntroduction to code optimization by dipankar
Introduction to code optimization by dipankar
 
Programming python quick intro for schools
Programming python quick intro for schoolsProgramming python quick intro for schools
Programming python quick intro for schools
 
C Programming Homework Help
C Programming Homework HelpC Programming Homework Help
C Programming Homework Help
 
M.TECH, ECE 2nd SEM LAB RECORD
M.TECH, ECE 2nd SEM LAB RECORD M.TECH, ECE 2nd SEM LAB RECORD
M.TECH, ECE 2nd SEM LAB RECORD
 
Computer Programming- Lecture 3
Computer Programming- Lecture 3Computer Programming- Lecture 3
Computer Programming- Lecture 3
 
Tutorial2
Tutorial2Tutorial2
Tutorial2
 

Destacado (20)

Savitch Ch 07
Savitch Ch 07Savitch Ch 07
Savitch Ch 07
 
Savitch ch 022
Savitch ch 022Savitch ch 022
Savitch ch 022
 
Savitch Ch 12
Savitch Ch 12Savitch Ch 12
Savitch Ch 12
 
Savitch Ch 10
Savitch Ch 10Savitch Ch 10
Savitch Ch 10
 
Savitch Ch 08
Savitch Ch 08Savitch Ch 08
Savitch Ch 08
 
Savitch ch 16
Savitch ch 16Savitch ch 16
Savitch ch 16
 
Savitch Ch 02
Savitch Ch 02Savitch Ch 02
Savitch Ch 02
 
Savitch Ch 13
Savitch Ch 13Savitch Ch 13
Savitch Ch 13
 
Savitch Ch 03
Savitch Ch 03Savitch Ch 03
Savitch Ch 03
 
Savitch Ch 18
Savitch Ch 18Savitch Ch 18
Savitch Ch 18
 
Savitch Ch 15
Savitch Ch 15Savitch Ch 15
Savitch Ch 15
 
Savitch c++ ppt figs ch1
Savitch c++ ppt figs ch1Savitch c++ ppt figs ch1
Savitch c++ ppt figs ch1
 
Savitch Ch 06
Savitch Ch 06Savitch Ch 06
Savitch Ch 06
 
Savitch Ch 11
Savitch Ch 11Savitch Ch 11
Savitch Ch 11
 
Savitch Ch 01
Savitch Ch 01Savitch Ch 01
Savitch Ch 01
 
Savitch ch 04
Savitch ch 04Savitch ch 04
Savitch ch 04
 
Savitch ch 01
Savitch ch 01Savitch ch 01
Savitch ch 01
 
Savitch Ch 17
Savitch Ch 17Savitch Ch 17
Savitch Ch 17
 
Savitch Ch 04
Savitch Ch 04Savitch Ch 04
Savitch Ch 04
 
Savitch Ch 05
Savitch Ch 05Savitch Ch 05
Savitch Ch 05
 

Similar a Savitch Ch 14

Lecture_7_StackAndRecursion (1).pptx
Lecture_7_StackAndRecursion (1).pptxLecture_7_StackAndRecursion (1).pptx
Lecture_7_StackAndRecursion (1).pptx
AbuHuraira729502
 
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
15AnasKhan
 

Similar a Savitch Ch 14 (20)

Unit-I Recursion.pptx
Unit-I Recursion.pptxUnit-I Recursion.pptx
Unit-I Recursion.pptx
 
Lecture_7_StackAndRecursion (1).pptx
Lecture_7_StackAndRecursion (1).pptxLecture_7_StackAndRecursion (1).pptx
Lecture_7_StackAndRecursion (1).pptx
 
14. Recursion.pdf
14. Recursion.pdf14. Recursion.pdf
14. Recursion.pdf
 
Recursion vs. Iteration: Code Efficiency & Structure
Recursion vs. Iteration: Code Efficiency & StructureRecursion vs. Iteration: Code Efficiency & Structure
Recursion vs. Iteration: Code Efficiency & Structure
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
algo_vc_lecture8.ppt
algo_vc_lecture8.pptalgo_vc_lecture8.ppt
algo_vc_lecture8.ppt
 
Recursion.ppt
 Recursion.ppt Recursion.ppt
Recursion.ppt
 
Python recursion
Python recursionPython recursion
Python recursion
 
Tail recursion
Tail recursionTail recursion
Tail recursion
 
Tail Recursion in data structure
Tail Recursion in data structureTail Recursion in data structure
Tail Recursion in data structure
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Recursion in c
Recursion in cRecursion in c
Recursion in c
 
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
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 
Amortized complexity
Amortized complexityAmortized complexity
Amortized complexity
 

Más de Terry Yoast

Más de Terry Yoast (20)

9781305078444 ppt ch12
9781305078444 ppt ch129781305078444 ppt ch12
9781305078444 ppt ch12
 
9781305078444 ppt ch11
9781305078444 ppt ch119781305078444 ppt ch11
9781305078444 ppt ch11
 
9781305078444 ppt ch10
9781305078444 ppt ch109781305078444 ppt ch10
9781305078444 ppt ch10
 
9781305078444 ppt ch09
9781305078444 ppt ch099781305078444 ppt ch09
9781305078444 ppt ch09
 
9781305078444 ppt ch08
9781305078444 ppt ch089781305078444 ppt ch08
9781305078444 ppt ch08
 
9781305078444 ppt ch07
9781305078444 ppt ch079781305078444 ppt ch07
9781305078444 ppt ch07
 
9781305078444 ppt ch06
9781305078444 ppt ch069781305078444 ppt ch06
9781305078444 ppt ch06
 
9781305078444 ppt ch05
9781305078444 ppt ch059781305078444 ppt ch05
9781305078444 ppt ch05
 
9781305078444 ppt ch04
9781305078444 ppt ch049781305078444 ppt ch04
9781305078444 ppt ch04
 
9781305078444 ppt ch03
9781305078444 ppt ch039781305078444 ppt ch03
9781305078444 ppt ch03
 
9781305078444 ppt ch02
9781305078444 ppt ch029781305078444 ppt ch02
9781305078444 ppt ch02
 
9781305078444 ppt ch01
9781305078444 ppt ch019781305078444 ppt ch01
9781305078444 ppt ch01
 
9781337102087 ppt ch13
9781337102087 ppt ch139781337102087 ppt ch13
9781337102087 ppt ch13
 
9781337102087 ppt ch18
9781337102087 ppt ch189781337102087 ppt ch18
9781337102087 ppt ch18
 
9781337102087 ppt ch17
9781337102087 ppt ch179781337102087 ppt ch17
9781337102087 ppt ch17
 
9781337102087 ppt ch16
9781337102087 ppt ch169781337102087 ppt ch16
9781337102087 ppt ch16
 
9781337102087 ppt ch15
9781337102087 ppt ch159781337102087 ppt ch15
9781337102087 ppt ch15
 
9781337102087 ppt ch14
9781337102087 ppt ch149781337102087 ppt ch14
9781337102087 ppt ch14
 
9781337102087 ppt ch12
9781337102087 ppt ch129781337102087 ppt ch12
9781337102087 ppt ch12
 
9781337102087 ppt ch11
9781337102087 ppt ch119781337102087 ppt ch11
9781337102087 ppt ch11
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Último (20)

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
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
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
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
 
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 ...
 
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
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).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.
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
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
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 

Savitch Ch 14