[Solved]Write Following C Program Make Sure Include Elements Start Empty List Empty Stack End Algo Q37260835
Write a following C++ program and make sure to includethese elements:
-
Start with an empty list and an empty stack. At the end of thealgorithm, the list will contain the correctly ordered tokens ofthe postfix expression. Next, for each token in the expression(split on whitespace):
-
if the token is a digit, simply append it to the list; else, thetoken must be either an operator or an opening or closingparenthesis, in which case apply one of the following options:
-
if the stack is empty or contains a left parenthesis on top,push the token onto the stack.
-
if the token is a left parenthesis, push it on the stack.
-
if the token is a right parenthesis, pop the stack and appendall operators to the list until you a left parenthesis is popped.Discard the pair of parentheses.
-
if the token has higher precedence than the top of the stack,push it on the stack. For our purposes, the only operators are +,-, *, /, where the latter two have higher precedecence than thefirst two.
-
if the token has equal precedence with the top of the stack, popand append the top of the stack to the list and then push theincoming operator.
-
if the incoming symbol has lower precedence than the symbol onthe top of the stack, pop the stack and append it to the list. Thenrepeat the above tests against the new top of stack.
-
-
After arriving at the end of the expression, pop and append alloperators on the stack to the list.
Expert Answer
Answer to Write a following C++ program and make sure to include these elements: Start with an empty list and an empty stack. At t… . . .
OR

