12 ms·
For those who struggle with RPN (postfix), it is really just a linearized tree. Starting with the infix a+bc The tree form of that is: + / \ a
by nyrikki 2y ago
For those who struggle with RPN (postfix), it is really just a linearized tree.
Starting with the infix a+bc
The tree form of that is:
+
/ \
a *
/ \
b c
If you walk around that tree, starting at the root counter-clockwise and looking left, only writing down an operator after you have seen both operands and you have postfix (RPN)
a b c * +
Same with postscript.