Link to home
Start Free TrialLog in
Avatar of slammer14
slammer14

asked on

Postfix to Infix

I am able to understand the infix to postfix, however I am having trouble with putting the parentheses back into the infix if I start with postfix.

Have looked at possibility of using 2 stacks, however I would like to
use only one.

I may not have made it clear.

What I need is to convert it to a fully parenthesized infix expression.


I don't understand how I get the parentheses in right spot

slammer 14


Please help!!

slammer14
Avatar of inpras
inpras

put some code here what U have tried so that we can help U
Avatar of ozo
What are the elements on your stack?  infix strings?
ASKER CERTIFIED SOLUTION
Avatar of bhattu
bhattu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,
  Here I am giving how we can evaluate postfix expression

Suppose the postfix expression is
  ab+c*
The corressponding infix expression is
  (a+b)*c

element   stack

  a         a       <-  Top
  b         a,b     <-  Top
  +         perform b+a & result is
            put onto top of the stack(a)
  c         a,c     <-  Top
  *         a*c

I think this will help U.

Sisu
Avatar of slammer14

ASKER

Edited text of question.
Sisu thanks it helps a little, however I don't need to calculate answer I just have to give the expression.

My email is slammer14@hotmail.com

Thanks
slammer
Adjusted points to 50
While evaluation is easy from postfix, you may find infix conversion more convenient from prefix.