Skip to content
Advertisement

Infix to Postfix short trick

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-

Advertisement

Answer

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.

Advertisement