Click here to Skip to main content
Sign Up to vote bad
good
See more: C++
I need help to convert an expression Postfix To Infix form in c++ program....
Plz any one help...
Posted 18 Jan '13 - 22:34

Comments
Garth J Lancaster - 19 Jan '13 - 4:56
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:35
Check out for Euler's Tour traversal technique for binary tree .... It may help

3 solutions

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
  Permalink  
Comments
SajeeshCheviry - 19 Jan '13 - 7:42
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?).
  Permalink  
Pseudo-code:
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
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Mahesh Bailwal 373
1 Sergey Alexandrovich Kryukov 354
2 Maciej Los 245
3 Rohan Leuva 175
4 CPallini 175
0 Sergey Alexandrovich Kryukov 9,287
1 OriginalGriff 7,204
2 CPallini 3,923
3 Rohan Leuva 3,211
4 Maciej Los 2,713


Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 20 Jan 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid