5. Convert infix + 2(/b...yu)) to postfix using a stack and the Infix to Postfix algorithm discussed in class. Notice th
Posted: Sat May 14, 2022 4:41 pm
5. Convert infix + 2(/b...yu)) to postfix using a stack and the Infix to Postfix algorithm discussed in class. Notice that the spaces are used to enhance readability only Infix to postfixFor your reference): • As long as there are more tokens, get the next token. • If the token is an operand, append it to the postfox string • If the token is "(.push it onto the stack. If the token is an operator, (order operators by precedence) If the stack is empty. push the operator onto the stack If the stack is not empty, pop operators of greater or equal precedence from the stack and append them to postfix string, stop when you encounter ")" or an operator of lower precedence or when the stack is empty. And then, push the new operator onto the stack When you encounter a "I", pop operators off the stack and append them to the end of the postfix string until you encounter matching "T". (Notice that is ignored/removed.) When you reach the end of the infix string, append the remaining content of the stack to the postfix string Please complete the following table. You must enter your explanation in the Explanation column for each token. Simply stating the answer or not using the required method(s) will result in Opoints awarded. (15 points) Token Explanation Postfix expression Stack (bottom to top) 3
b Z ) Y п ) ) (
b Z ) Y п ) ) (