Click here to Skip to main content
12,458,005 members (53,664 online)
Rate this:
 
Please Sign up or sign in to vote.
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:34pm
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
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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:42am
   
you are right:-)
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

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
Top Experts
Last 24hrsThis month


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100