英文:
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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论