Say what an entry means
transcript
A stack problem looks hard at first. Do not start with the code. Answer two questions first, out loud. They give you every update.
First, what does an entry mean? Second, which event removes it?
A formula has brackets. An open bracket pushes the total and the sign. A close bracket folds the group back in. Ten minus a group worth six is four.
For brackets, an entry is an open position. A close bracket pops the top. The run reaches back to the new top.
Every entry stands for something that is still open. The top entry is always the newest of them. One event closes an entry and removes it from the stack.
Test the empty input, where nothing was ever pushed. Test a single entry, where the stack has one item. Test an input that ends with entries still open.
Five problems share this one habit. Two sentences each, before any code.
Say what an entry means. Say what removes it. Full breakdown in the lecture.