Solved

Change Postfix/Infix/Prefix notations using a Stack

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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Article by: Nadia
Linear search (searching each index in an array one by one) works almost everywhere but it is not optimal in many cases. Let's assume, we have a book which has 42949672960 pages. We also have a table of contents. Now we want to read the content on p…
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 shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
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…

829 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