|
|
Subject:
postfix to infix
Category: Miscellaneous Asked by: joao-ga List Price: $2.00 |
Posted:
16 Sep 2002 04:28 PDT
Expires: 16 Oct 2002 04:28 PDT Question ID: 65507 |
program that converts a postfix expression to infix, using a pushdown stack |
|
Subject:
Re: postfix to infix
Answered By: dogbite-ga on 18 Sep 2002 20:40 PDT |
You want a program to convert something like ( 3 ( 4 2 + ) 5 * ) to ( ( 3 * ( 4 + 2 ) ) * 5 ) Suppose you have a list of tokens ('(', numbers, operators, ')') as the programs input. The algorithm is: if [token is '('] then push '(' on the stack else if [token is number] then push number on the stack else if [token is operator] then while pop off two elements a,b if top element on stack is '(' then pop off the '(' push back on "(a operator b)" break while else push back on "(a operator b)" end while else if [token is ')'] then discard |
|
There are no comments at this time. |
If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you. |
Search Google Answers for |
Google Home - Answers FAQ - Terms of Service - Privacy Policy |