Solved

Change Postfix/Infix/Prefix notations using a Stack

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Scrum and Sprint Product Backlog 3 179
mirrorEnds challenge 6 145
sumDigits  challenge 7 141
Java. Convert method from recursion based to iteration based ( loop based ) 6 118
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…
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…
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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