中缀转后缀的简便方法

huangapple go评论75阅读模式
英文:

Infix to Postfix short trick

问题

有人知道中缀转后缀表达式转换的快捷方式或技巧吗?

我知道使用栈的方法,但是有没有更快的技巧呢?

例如,将 a+b*(c^d-e)^(f+gh)-i 转换为 abcd^e-fgh+^*+i-

英文:

Does anybody know a shortcut or short trick for infix to postfix conversion for multiple-choice questions exam?

I know the method using stack but is there any fast technique for it?

for example a+b*(c^d-e)^(f+gh)-i to abcd^e-fgh+^*+i-

答案1

得分: 0

将表达式作为树写出(叶子为值,内部节点为运算符),保留值的从左到右顺序,然后写下它的后序遍历。

英文:

Write the expression as a tree (leaves are values, internal nodes are operators), preserving the left-to-right order of values, and then write down its post-order traversal.

答案2

得分: 0

Sure, here's the translation:

如何使用"Shunting Yard"算法:https://en.m.wikipedia.org/wiki/Shunting-yard_algorithm

英文:

How ‘bout the Shunting Yard algorithm: https://en.m.wikipedia.org/wiki/Shunting-yard_algorithm

huangapple
  • 本文由 发表于 2020年9月28日 23:32:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/64105232.html
  • c++
  • data-structures
  • infix-notation
  • java
  • postfix-notation

告诉编译器一个等同于它所需的 go 63
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定

  • 开发者交流平台

    本页二维码