Skip to main content

Infix / Prefix / Postfix

Learn Infix / Prefix / Postfix (Stack, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

The Three Notations Infix - operator BETWEEN operands: a + b . Natural for humans, ambiguous for computers without precedence rules and parentheses. Prefix (Polish Notation) - operator BEFORE operands: + a b . No parentheses or precedence ever needed - the structure is unambiguous just from token order. Postfix (Reverse Polish Notation) - operator AFTER operands: a b + . Same unambiguous property as prefix; this is what calculators and stack machines actually evaluate internally.

More lessons in Stack