Table of Contents
Data Abstraction and Structures Using C++Headington and Riley Chapter 6Recursion (continued)
Recall that . . .
What is the value of rose(25)?
Finding the value of rose(25)
Writing recursive functions
Recursive Function Call
Finding a Recursive Solution
General format formany recursive functions
Three-Question Method of verifying recursive functions
Guidelines for writing recursive functions
struct ListType
Recursive function to determine if value is in list
PPT Slide
When a function is called...
Stack Activation Frames
PPT Slide
Run-Time Stack Activation Records x = Func(5, 2); // original call at instruction 100
PPT Slide
Run-Time Stack Activation Records x = Func(5, 2); // original call at instruction 100
Run-Time Stack Activation Records x = Func(5, 2); // original call at instruction 100
Run-Time Stack Activation Records x = Func(5, 2); // original call at instruction 100
Run-Time Stack Activation Records x = Func(5, 2); // original call at line 100
Show Activation Records for these calls
An example where recursion comes naturally
PPT Slide
Extending the definition
PPT Slide
Write a function . . .
PPT Slide
Write a function . . .
PPT Slide
Function BinarySearch( )
x = BinarySearch(a, 0, 14, 25 );
PPT Slide
PPT Slide
Use a recursive solution when:
Write a function . . .
PPT Slide
|
Author: Sylvia Sorkin
Email: ssorkin@essex.cc.md.us
Home Page: http://www.essex.cc.md.us/Essex/People/ssorkin/index.html
Download presentation source
|