We can construct meaningful derivation trees that enable us to represent arithmetic expressions in infix, prefix and postfix forms. A binary tree is enough to represent all these three notations of arithmetic expressions. Both prefix and postfix notations are unintelligable for humans. But they are of great use in computer science.
Compilers often convert infix to prefix notation and then to assembler code. From a derivation tree of an algebraic expression, we can get equivalent prefix and postfix notations. An algebraic expression in terms of operators and operands can be derived by an ambiguous context-free grammar. Prefix notation is the parenthesis-free notational scheme invented by Polish logician Jan Lukasiewicz and is often called polish notation. In prefix notation operators are followed by operands.
For example, in prefix notation
A + B is written as
+AB. Postfix notation is reverse of prefix notation.
AB+ is the equivalent postfix notation of
A + B. The infix form is evaluated and the binary tree is created according to the priority of the operators. Let us start from the simplest examples.