0% found this document useful (0 votes)
272 views

Calculation of Postfix Expression

1. Postfix notation, also known as postfix or reverse Polish notation, is a notation for writing arithmetic expressions where the operators follow the operands. 2. To calculate a postfix expression using a stack, the operands are first pushed onto the stack and then the operators are applied by popping the top two operands, applying the operator, and pushing the result back onto the stack. 3. Converting an infix expression to postfix involves following precedence rules and parenthesizing subexpressions, then removing parentheses and writing the operators after the operands.

Uploaded by

Falak Jani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
272 views

Calculation of Postfix Expression

1. Postfix notation, also known as postfix or reverse Polish notation, is a notation for writing arithmetic expressions where the operators follow the operands. 2. To calculate a postfix expression using a stack, the operands are first pushed onto the stack and then the operators are applied by popping the top two operands, applying the operator, and pushing the result back onto the stack. 3. Converting an infix expression to postfix involves following precedence rules and parenthesizing subexpressions, then removing parentheses and writing the operators after the operands.

Uploaded by

Falak Jani
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

|| 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.

|| A!"AN#A$E %& '(IN$ P%(#&I) N%#A#I%N || || N%#A#I%N C%N"E*(I%N( ||


#n expression # ' $ 4 2 is gi-en in which is in infix notation. To calculate this expression for -alue a56 b53 c57 repressi-ely we must follow certain rule. # '$ 4 2 56'347 5747 5 68

|| %PE*A#%* P*%*I#+ ||
9:PO%9%TI#+ OP9;#TO; 3ultiplication ? @i-ision #ddition ? >ubtraction < 4 ? ' ! )I=)9>T 3iddle +ower

||#,E *'-E( #% BE *E.E.BE*E! !'*IN$ IN&I) || || #% P%(#&I) C%N"E*(I%N ||


1. Parenthesi,e the expression starting from left to right. 2. @uring parenthesi,ing the expression the operands associated with operator ha-ing higher precedence are first parenthesi,ed. 3. The sub!expression which has been con-erted into postfix is to be treated as single operand. 6. Ones the expression is con-erted to postfix from remo-e the perenthesis.

You might also like