Calculation of Postfix Expression
Calculation of Postfix Expression
On of the application of stack is calculation of postfix expression. To understand what a postfix expression let is we undergo a discussion. There are basically three type of notation for an expression. 1. Infix notation 2. Prefix notation 3. Postfix notation. (1) Infix notation: The infix notation is what we come across in our general mathematics where the operator is written in!between the operand. "or example the expression to add two numbers # and $ is written in infix notation as A+B %ote that the operator &'( is written in between the operands # and $. the reason why this notation is called infix is the place of operator in the expression. (2) Prefix notation: )e prefix notation a notation which the operator is written before the operands it is also called polish notation in the honor of the mathematician *an +ukasiewic, who de-eloped this notation. The same expression when in prefix notation looks like. +AB #s the operator &'( is written before the operands # and $ this notation is called prefix notation. (3) Postfix Notation: In the postfix notation the operators are written after the operands so it is called the postfix notation. It is also known as suffix notation or re erse polish notation. This abo-e expression if written in postfix notation looks like follows. add/# $0 The operator add/name of function0 precedes the operands # and $. because the postfix notation is a type of notation which is must suitable for a computer to calculate any expression and is the uni-ersally accepted notation for designing arithmetic and logical /#+10 unit of the 2P1. Therefore it is necessary use to study the postfix notation. 3oreo-er the postfix notation is the way computer looks towards notation stored in stack and then calculated. In the presiding section we will study the con-ersion of an expression from one notation to other.
|| %PE*A#%* P*%*I#+ ||
9:PO%9%TI#+ OP9;#TO; 3ultiplication ? @i-ision #ddition ? >ubtraction < 4 ? ' ! )I=)9>T 3iddle +ower