Solved

Change Postfix/Infix/Prefix notations using a Stack

Posted on 2008-06-18
4
10,435 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Iteration: Iteration is repetition of a process. A student who goes to school repeats the process of going to school everyday until graduation. We go to grocery store at least once or twice a month to buy products. We repeat this process every mont…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
This video discusses moving either the default database or any database to a new volume.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

18 Experts available now in Live!

Get 1:1 Help Now