Modify Existing Programs
Some possible exercises:
Replace use of one construct with another
Replace one algorithm by another
Replace global variables by local ones
Change data structure for task (e.g., array implementation by linked list)
Modify code segment to achieve different purpose (e.g., print list in reverse order rather than forward order)
Replace complex recursion by tail recursion
Sample Laboratory Exercises
Lab 36, Local Procedures
(in the Scheme programming language), from CSC 151,
Fundamentals of Computer Science I
For several examples,
Explain standard recursive pattern and a trace of procedure call and return
Draw diagrams to explain trace
Add running (local) parameter
Make algorithm tail recursive (and explain procedure trace)
Translate to basic local procedure and procedure invocation
Translate to simplified local procedure and invocation
After reading and explaining one example, write same progression for second example
created May 4, 2003
last revised May 4, 2003
previous
next