Professional Documents
Culture Documents
FORMS OF EXPRESSIONS
1.)INFIX-----A+B When the operator lies between the operants.
2.)POSTFIX------AB+ When the lies post the two operants.
3.)PREFIX-------+AB When the operator lies pre the two operants.
ORDER OF PRECEDENCE
() -----BRACKET IS SOLVED FIRST
^ ------HIGHEST PRIORITY
*/------MIDDLE PRIORITY
+- -------LOWEST PRIORITY
(HH(WW))----- FIRST INNER BRACKET IS SOLVED
A+B/C-D (INFIX)
A+(B/C)-D
A+(BC/)-D
(A+(BC/))-D
(A(BC/)+)-D
(ABC/+)-D
((ABC/+)-D))
ABC/+D- (POSTFIX)
In this INFIX Form is converted to PREFIX Form.
Rules:
1. All operands are to be PRINTED in Output column.
2. All operators are to be PUSHED in Stack column.
3. WHEN CLOSING BRACKET comes, POP and PRINT 1 operator
from the TOP of the stack.
4. Ignore the Opening Bracket if its closing bracket comes (from
next step onwards).
5.
NOT (HIGHEST)
AND (MIDDLE)
OR (LOWEST)
[(TRUE AND [NOT FALSE]) OR (FALSE OR[NOT TRUE])]
STEP INPUT ACTION STACK OUTPUT
1 ( PUSH (
2 TRUE PRINT ( TRUE
3 AND PUSHOT (AND TRUE
4 NOT PUSH (AND,NOT TRUE,FALSE
5 FALSE PRINT (AND,NOT TRUE,FALSE
POP AND (AND TRUE,FALSE,
PRINT