COMP 2140 Lecture 9: 10_03_stack_queue.pdf
Document Summary
A stack can be used to verify whether a string contains balanced braces. When you reach the end of the string, you have. For each character from left to right in a string if stack is not empty pop the stack else if stack is empty. For each character from left to right in a string if stack is not empty and the top of the stack is a matching opening grouping symbol pop the stack else unbalanced. Infix expression: operator is written in between two operands. Postfix expression: operator is written after two operands. Prefix expression: operator is written before two operands. Pushes the result of the operation on the stack. Data: a collection of items organized in a first- in first-out scheme. Items are inserted at the end of the list, and are accessed/removed at the front of the list. Examples of queue: telephone operator serving customers at a cashier scheduling printing jobs in a shared printer.