conversion from infix to prefix

后端 未结 14 1307
有刺的猬
有刺的猬 2020-12-09 10:24

I am preparing for an exam where i couldn\'t understand the convertion of infix notation to polish notation for the below expression:

(a–b)/c*(d + e – f / g)         


        
14条回答
  •  北海茫月
    2020-12-09 10:43

    Infix to PostFix using Stack:

         Example: Infix-->         P-Q*R^S/T+U *V
         Postfix -->      PQRS^*T/-UV
    
         Rules:
        Operand ---> Add it to postfix
        "(" ---> Push it on the stack
        ")" ---> Pop and add to postfix all operators till 1st left parenthesis
       Operator ---> Pop and add to postfix those operators that have preceded 
              greater than or equal to the precedence of scanned operator.
              Push the scanned symbol operator on the stack
    

提交回复
热议问题