Click here to Skip to main content
15,900,253 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need help to convert an expression Postfix To Infix form in c++ program....
Plz any one help...
Posted
Comments
Garth J Lancaster 19-Jan-13 4:56am    
What code have you written so far ? - What is the specific nature of your issue ?? - this problem has been solved and solutions posted all over the NET - so why dont you find one, try it, and then post back when you have a specific issue ...

If you really cant find a starting point, check out these

https://medium.com/tech-talk/f16ab7ba73b4
http://semocsc.com/forum/viewtopic.php?f=10&t=7

PrafullaVedante 21-Jan-13 3:35am    
Check out for Euler's Tour traversal technique for binary tree .... It may help

First implement the process of converting postfix to infix using your notebook.

After figuring out the method implement with C++, that was how I did as well as all other programmer did
 
Share this answer
 
Comments
SajeeshCheviry 19-Jan-13 7:42am    
you are right:-)
Let Me Goggle That For You[^].
However I would suggest yoo to make at least an attempt based just on you theoretical knowledge (did you study the matter, right?).
 
Share this answer
 
Pseudo-code:
C++
string input = ReadInput();
Stack<string> stack;
foreach(string token in GetTokens(input)) {
   if (IsOperator(token)) {
      string a = stack.Pop();
      string b = stack.Pop();
      stack.Push("(" + b + token + a + ")");
   } else {
      stack.Push(token);
   }
}
print(stack.Pop());

No error handling shown above, i.e. garbage-in→garbage-out.
Conversion into C++ is left to you as exercise.

Good Luck!
Andi
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900