Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

DATA STRUCTURES

ASSIGNMENT 1
Q.) USING CONCEPTS OF STACKS. DESCRIBE
PSEUDOCODE TO CONVERT POSTFIX TO INFIX
EXPRESSION.ALSO USE AN EXAMPLE TO EXPLAIN THE
SAME
Answer:

Let S be an empty stack. Let PF be an postfix expression i.e. AB*CD*/. Let IF be an


infix expression initially empty.

While (PF expression is not ended)

Read next character from PF

If (character is an operand)

Push(S, character)

Else

Operand2=pop(s)

Operand1=pop(s)

Put it into IF expression

Let x be temporary variable such that operand1 & operand2 are stored in it.

x=operand2 symbol operand1

IF = x

x=0

}
EXAMPLE:-

Let us take a postfix expression. Say for e.g. AB*CD*/. As soon as we get an
operand we have to push that element in to the stack. We get an operator we have
to pop the element which was in the stack.

You might also like