C SC 205 Lecture 6: Recursion, Part 1
major resources: Data Structures and the Java Collections Framework Second Edition,
William Collins, McGraw-Hill, 2005
Introduction to Programming and OO Design
using Java, Niño and Hosch, Wiley & Sons, 2002
[ previous
| schedule
| next ]
Wednesday September 26 (week 3)
preliminary: review of parameter passing
- Java uses pass by value, period. Value passed to method may be primitive value or object reference.
- object whose reference is argument can be modified by callee (note: making reference final does not prevent)
- similarity of parameter passing and assignment w.r.t. type compatibility (subclass substitution)
Towers of Hanoi Demonstration and Analysis
- analyzing Towers of Hanoi through demonstration
- Sequence of moves to solve 1-disk problem
- Sequence of moves to solve 2-disk problem
- Sequence of moves to solve 3-disk problem
- Preduct sequence of moves to solve 4-disk problem
- Predict how many moves needed to solve 4-disk problem
- Predict how many moves needed to solve N-disk problem (Big O)
- notice pattern of moves and their self-similarity
- self-similarity is characteristic of problem with naturally recursive solution
[ C
SC 205 | Peter
Sanderson | Math Sciences server
| Math Sciences home page
| Otterbein ]
Last updated:
Peter Sanderson (PSanderson@otterbein.edu)