Solved

Change Postfix/Infix/Prefix notations using a Stack

Posted on 2008-06-18
4
10,459 Views
Last Modified: 2012-05-05
How do I change a given expression in infix notation to prefix and postfix notations using a stack?? Step by step?? What would be the state of the stack during the process??

lets say the next expression: (3+4)*6/2
0
Comment
Question by:axtur
4 Comments
 
LVL 84

Assisted Solution

by:ozo
ozo earned 100 total points
ID: 21817826
0
 
LVL 23

Accepted Solution

by:
Christopher Kile earned 200 total points
ID: 21817851
This sounds like a homework problem, so no specific solution will be offered until you convince me otherwise.

That said, I suggest to you first that you translate your infix expression into prefix and postfix forms, and remember that parentheses promote the surrounded expression to a greater precendence than any operator.
0
 

Author Comment

by:axtur
ID: 21817962
This is not a homework problem, it is a solution to an exam from the last year, the real expression given was like 8 times that. The expresion can be that or any other, I don't mind, I just need a simple example with the trouble combinations (what to do when there are two operators in the stack? when to push an operator or a number?)

I just want to know the stack algorithm, the process. When to push and when to pop from the stack.

Can be a expression translated from postfix directly to prefix or do I need first to go thru the infix form?
0
 
LVL 24

Assisted Solution

by:purplepomegranite
purplepomegranite earned 200 total points
ID: 21818000
A very good walkthrough of infix to postfix notation is here: http://en.wikipedia.org/wiki/Shunting_yard_algorithm
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Before You Read The Article Please make sure you understand these two concepts: Variable Scope (http://www.php.net/manual/en/language.variables.scope.php) and Property Visibility (http://www.php.net/manual/en/language.oop5.visibility.php).  And to …
Introduction A frequently used term in Object-Oriented design is "SOLID" which is a mnemonic acronym that covers five principles of OO design.  These principles do not stand alone; there is interplay among them.  And they are not laws, merely princ…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now