# Infix vs postfix vs prefix - which has the smallest processing time

Infix, prefix (polish notation) and postfix (reverse polish notation) are all forms of arithmetic operations. As I understand it, infix is what we use in maths where the rules of BODMAS (Bracket, Order, Division and Multiplication, Addition and Subtraction) are used to decide what order the operations are used in. I can understand this being more computationally expensive to calculate than pre/post fix as the processor would have to reorder the equation so that it follows BODMAS. However, I do not understand why there is both prefix and postfix as they just change the order of tree traversal, so logically would take the same amount of processing time as each other. Is there any reason for choosing one over the other, and is my belief of infix being slower than post/prefix correct?

## 1 Answer

You can express the same in prefix and postfix without brackets.

For example, a + b * c can be ambiguous so it can give 2 different results so you need some precedence to solve the expression(as you have mentioned BODMAS) but both the trees if traveled in prefix or postfix leads to a unique results like (a + b) * c will have postfix ab+c* and a + (b * c) will have abc*+.