Next: About this document ...
Up: Assignment 5: Stacks
Previous: File I/O
Starting with the code from the previous section, we would
like to write a program that reads a Java source code file and
that checks whether the the parentheses, braces, and brackets
in the program are balanced.
- 1.
- Write a paragraph or two explaining how you would use the
Stack ADT to check balance. Why isn't it enough to just count
the number of open and close parentheses and make sure they match?
Why is a stack well-suited to this task?
- 2.
- Once you have an algorithm, make a plan that details at least
three intermediate stages between where the program is now and where
it is going. Each stage should be a small modification of its
predecessor, it should use a new feature or add a new function,
and it should be testable.
- 3.
- After we have discussed the planning stage in class, go ahead
and implement it.
Allen B. Downey
1999-10-14