Next:
Summary
Up:
All Units
Unit 11
Recursion
Summary
Inductively defined domains
Inductively defined domains and recursion
Example: recursive implementation of the sum between two integers
Example: recursive implementation of the product between two integers
Example: recursive implementation of the power between two integers
Comparison between recursion and iteration
Example: number of occurrences of a character in a string
Example: maximum of positive integers read from a file
Comparison between loop for reading and recursive reading
Example: the last ones will be the first ones
Counting elements using recursion
Conditional counting of elements using recursion
Computing values using recursion
Run-time memory management
Heap management and garbage collection
Stack of activation records
Example of evolution of the stack of activation records
Evolution of the stack of ARs in the case of recursive methods
Example: the last ones will be the first ones (cont'd)
Example: palindrome string
Example: symmetric sequence of integers
Multiple recursion
Example: Towers of Hanoi
Number of activations in the case of multiple recursion
Example: traversal of a moor
Moor: representation of a moor
Moor: solution of the traversal problem
Moor: construction of the traversal
Exercises
Next:
Summary
Up:
All Units