Advertisements
Advertisements
प्रश्न
Convert the following infix notations to postfix notations, showing stack and string contents at following step.
A + B - C * D
संक्षेप में उत्तर
Advertisements
उत्तर
Infix Expression is : A + B - C * D
Scanning from Left to Right
| Symbol | Action | Stack, Initially Stack is Empty [ ] | Postfix Expressions |
| A | Append to Postfix Expression | [ ] | A |
| + | PUSH(‘+’) | + | A |
| B | Append to Postfix Expression | + | A B |
| – | – have equal precedence to +. First POP(‘+’) then PUSH(‘-‘) | – | A B + |
| C | Append to Postfix Expression | – | A B + C |
| * | * have higher precedence than -, PUSH ‘*’ | – * | A B + C |
| D | Append to Postfix Expression | – * | A B + C D |
| End of Expression | POP all and add to Postfix Expression | [ ] | A B + C D * – |
shaalaa.com
Conversion from Infix to Postfix Notation
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
