Stack Operation Demonstration Program w/ Parens
An parenthetic expression is evaluated as follows.
-
The expression is scanned from left to right.
-
If an opening paren is encountered, it is pushed onto the stack.
-
If a closing paren is encountered, it is compared to the top opening paren
on the stack. If they correspond, the applet continues. If they do not,
the applet finishes with a message that the expression is unacceptable.
-
When you provide an expression to be evaluated,
separate chars with spaces
as in [ ( ) [ ( ) ] ],
Source Code of the Matching Program
Source Code of the MatchingG Program (Graphical Version)
Jacob's CS 261 Demos
Jacob's CS 261 Home