?
Solved

Change Postfix/Infix/Prefix notations using a Stack

Posted on 2008-06-18
4
Medium Priority
?
10,526 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 84

Assisted Solution

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

Accepted Solution

by:
Christopher Kile earned 600 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 600 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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Article by: Nadia
Suppose you use Uber application as a rider and you request a ride to go from one place to another. Your driver just arrived at the parking lot of your place. The only thing you know about the ride is the license plate number. How do you find your U…
Software development teams often use in-memory caches to improve performance. They want to speed up access to, or reduce load on, a backing store (database, file system, etc.) by keeping some or all of the data in memory.   You should implement a…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

650 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