Infix to postfix converstion

 Infix to Postfix Conversation 

Procedure :-

1.Scan the infix string from left to right .

2.Initialise an empty stack 

3.If the scanned character is an operand,add to the postfix string .

4.If the scanned character is an operator, and if the stack is empty push the character to stack.

5.Repeat 4 steps till the characters are scanned.

6.After all characters are scanned, we have to add any character that the stock may have to the postfix string .

7.If stock is not empty add Top stack to postfix string and pop the stack.

8.Repeat the steps as long as stack is not empty.

Conversation Infix to Postfix

Ex:-

(a+b)*(c-d)

in put out put
(a+b)*(c-d)
(+b)*(c-d) 
b*(c-d)
*(c-d)
*(-d) 
*(-)
*
Empty
a
a+
ab+
ab+c
ab+cd
ab+cd-
((ab+)(cd-))

Comments

Popular posts from this blog

History of C language

Lab programs of C

Algorithm Pseudopods Flow-chat