后缀为缀谈话 [英] Postfix to Infix conversation

查看:168
本文介绍了后缀为缀谈话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我解决不了这个前pression从后缀为缀。请帮我详细了解

  5 x和y  -  / X Y + 3 ^ 7 / +


解决方案

后缀为缀:

  5 x和y  -  / X Y + 3 ^ 7 / +

步骤

5 x和y - /结果
   A)5xy- / 5 =(X-Y)/ =(5 /(X-Y))结果
   X Y +结果
   B)X Y + =(X + Y)结果
      (X + Y)3 ^结果
      B.1)(X + Y)3 ^ =((X + Y)^ 3)结果,
  现在,(5 /(X-Y))((X + Y)^ 3)7 / +搜索
    =(5 /(X-Y))(((X + Y)^ 3)/ 7)+
    =(5 /(X-Y))+(((X + Y)^ 3)/ 7)

字尾和preFIX是前pression其中使用没有括号。运营商的precedence都决定在那里的前pression出现的顺序,所以要评估前pression无需搜索下一个操作perform-的快速

而中缀前pression $ P $运营商pcedence被支架覆盖。因此,括号内是有中缀前pression-需要搜索来执行的操作如A + B%D - 因此 SLOW 结果。
这就是原因所在转换是在计算机科学中非常有用。

I can not solve this expression from postfix to infix. Please help me to understand in detail

5 x y - / x y + 3 ^ 7 / +

解决方案

postfix to infix:

5 x y - / x y + 3 ^ 7 / +

STEP

5 x y - /
A) 5xy-/ = 5 (x-y)/ = (5 / (x-y))
x y +
B) x y + = (x + y)
(x+y) 3 ^
B.1) (x + y) 3 ^ = ((x + y) ^ 3 )
Now, (5 / (x-y)) ((x + y) ^ 3 ) 7 / +
= (5 / (x-y)) (((x + y) ^ 3 )/7 ) + = (5 / (x-y)) + (((x + y) ^ 3 )/7 )

POSTFIX and PREFIX are expression in which no brackets are used. Precedence of operator are decided in order of there appearance in expression, So to evaluate expression no need to search next operation to perform- FAST .

While in INFIX expression precedence of operators are overwritten by brackets. hence brackets are there in infix expression- Need to search which operation to perform e.g. A+B%D - hence SLOW.
That is the reason conversion are useful in computer science.

这篇关于后缀为缀谈话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆