4. Binary tree

You can use a binary tree to convert between infix and reverse Polish notation. (we have a mini-web here if you want to remind yourself about binary trees)

Consider the example shown below which is using infix notation

(6(4+5) - 25)/(2+3)

and the same example in reverse polish notation

6 4 5 + * 25 - 2 3 + /

Both can be derived from the binary tree laid out below


algebraic expresson and binary tree

The next page will show how this can be used to produce the expression in reverse Polish notation.



Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Binary trees and reverse polish



Copyright © www.teach-ict.com