This repository contains a simple algorithm written in C to convert an infix expression to a postfix expression.
You're already familiiar with infix expressions. Infix expressions are expressions that contain operators (+-*/) between operands (numeric constants).
Examples of infix expression are:
2 * 6 + 1 / 4
5 * (7 - 5)
According to Silvio do Lago Pereira, in its book titled "Estrutura de Dados em C", there is a big problem with infix expressions: the existence of priorities, either due the operators (*
and /
have higher priority) or due parenthesis.
So, a long time ago, Jan Lukasiewicz created a different way of treating expressions and called it postfix notation or reverse Polish notation.
Basically, it consists of moving the operators to after the operands - not between anymore.
The previous infix expressions written in postfix notation are:
2 6 * 1 4 / +
(7 5 -) 5 *
The advantage of this notation for computational programs is that they can be easily interpreted using a Stack abstract data type.