InterviewSolution
| 1. |
How to convert infix to postfix and evaluate postfix expression? |
|
Answer» One of the most important applications of the Stack is the arithmetic expressions’ conversion into the programming languages of high-level into a form that the machine can read. Because the computer system can understand as well as work only on the binary language, the system assumes that the arithmetic operation is able to take place only in two operands, for example, A+B, D/A, and others. But in the usual form, one arithmetic expression can consist of two or more operators plus two operands for example (A+B)*C(D/(J+D)). Infix ExpressionThis expression follows this scheme that is an is being preceded as well as succeeded by the . This kind of expression is known as infix expression. For example, A+B, etc. Postfix ExpressionThis expression follows this scheme that is an is being succeeded by two . For example, AB+, etc.How to convert the Infix Expression To a Postfix ExpressionLet, X, be one arithmetic expression that is written in the infix notation. Now, this algorithm FINDS or needs an equivalent postfix notation Y.
|
|