COM SCI 32 Lecture Notes - Lecture 5: Fifo (Computing And Electronics), Postfix (Software), The Queue
Document Summary
Cs 32 - lec 5 - stacks & queues. Stacks: last in first out (stack of trays) - items are always added to one end. Infix postfix (15+6) * 5 15 6 + 5 * Queue: first in, first out (line of customers) has a front and a rear. Look at the back item in the queue. Output: postfix string (initially empty: start with the left-most item. If == number: append to the end of postfix string followed by a space. If == operator && stack is empty: push operator onto stack. If == operator && stack is not empty. 5: pop all operators with greater or equal precedence off the stack, append them onto the postfix string, stop when reach an operator w/ lower precedence or a ( , push the new operator onto the stack. Output: answer: start with the left-most item. If == number: push it onto the stack.