Hi, can you please write the symbol stack and output of the following equation as it is converted from infix to postfix using the standard stack algorithm?
u + (e / (c + z)) + b / s
Notes:
- The Stack and Output columns show the state of the stack and the output string after the symbol in that row has been processed.
- All symbols are only one character, so you don't need to include any spaces.
- The stack fills from the right, i.e., the rightmost item in the stack is the top item.
- The last row should contain nothing in the Symbol and Stack columns, that is, it should just contain the final output.
- Empty rows will be ignored.
The standard algorithm:
# Standard infix to postfix algorithm
for each symbol s:
if s is an operand, output s
else if it is a left parenthesis, push s
else if it is a right parenthesis, pop to output until the corresponding left parenthesis is popped
else # it is an operator
push s
pop all remaining operators to output