Computer Science, asked by hrishisgp97, 1 month ago

convert the infix to postfix for A-(B+C)*(D/E)​

Answers

Answered by veditha012
0

Answer:

ABC+DE/​*-

Explanation:

Attachments:
Answered by ankhidassarma9
0

Answer:

The Postfix Expression for the given Infix Expression A-(B+C)*(D/E)​ is ABC+DE/*-

Explanation:

  • The given Infix is :  A-(B+C)*(D/E)​
  • Conversion of Infix expression to Postfix expression:

Symbol                              Postfix string                    Stack

A                                            A

-                                             A                                         -

(                                             A                                         -(

B                                           AB                                       -(

+                                            AB                                       -(+

C                                           ABC                                     -(+

)                                            ABC+                                   -

*                                            ABC+                                   -*

(                                            ABC+                                   -*(

D                                          ABC+D                                -*(

/                                            ABC+D                                -*(/

E                                           ABC+DE                              -*(/

)                                            ABC+DE/

                                            ABC+DE/*-

So, the Postfix Expression for the given Infix Expression is ABC+DE/*-

  • Algorithm to convert Infix  to Postfix

Step 1 : Scan the given Infix Expression from left to right.

Step 2 : If the scanned character is an operand, put it  to Postfix string.

Step 3 : Else,

      Step 3.1 : If the precedence order of the scanned operator is greater

      than the precedence order of the operator in the stack or the stack is

      empty or the stack contains a ‘(‘ or ‘[‘ or ‘{‘, push the operator on

      stack.

      Step 3.2 : Else, Pop all the operators from the stack which are

      greater  than or equal to in precedence than that of the scanned

      operator and then Push the scanned operator to the stack. If

      there is a parenthesis while popping then stop there and push

      the scanned operator in the stack.

Step 4 : If the scanned character is an ‘(‘ or ‘[‘ or ‘{‘, push it to the stack.

Step 5 : If the scanned character is an ‘)’or ‘]’ or ‘}’, pop from the stack

           and add it to the Postfix string  until a ‘(‘ or ‘[‘ or ‘{‘ respectively is

           encountered, and then discard both the parenthesis.

Step 6 : Repeat steps 2-6 until infix expression is scanned completely.

Step 7 : Print the Postfix string    

Step 8 : Pop and add to the Postfix string from the stack until it is not

             empty.  

For More such type of Conversion , click here->

https://brainly.in/question/7429503

https://brainly.in/question/42561619            

Similar questions