Balanced Parentheses, ctd.
The algorithm in the book uses a stack. Left parentheses are pushed on the stack as they are read. Every time a right parenthesis is read, the corresponding left parenthesis is popped. If parentheses balance, at the end of the input line the stack is empty and no underflow occurred.
The algorithm keeps track of *which* parentheses balance!