954,536 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Infix to postfix using queue

Hello,

I wanna write a method that recieves an argument of type String which is a mathematical expression in infix mode, then change it to postfix and store in a queue and return the queue...how do i go about that?? I have created so far a Queue class, Node class.

soUPERMan
Light Poster
43 posts since Feb 2010
Reputation Points: 10
Solved Threads: 3
 

use SITE SEARCH:
http://www.daniweb.com/forums/search.php
keywords: infix postfix
read a book:
http://www.brpreiss.com/books/opus5/

Attachments cover150.gif 27.38KB
quuba
Posting Pro
573 posts since Nov 2008
Reputation Points: 123
Solved Threads: 106
 

Thanks quuba, one more question though...if i want to use a queue, must i only use it with something like a linkedlist or such similes??

soUPERMan
Light Poster
43 posts since Feb 2010
Reputation Points: 10
Solved Threads: 3
 

All ways are allowed.
Look at http://en.wikipedia.org/wiki/Reverse_Polish_notation
Converting from infix notation
Main article: Shunting-yard algorithm

Edsger Dijkstra invented the Shunting-yard algorithm to convert infix expressions to postfix (RPN), so named because its operation resembles that of a railroad shunting yard.

There are other ways of producing postfix expressions from infix notation. Most Operator-precedence parsers can be modified to produce postfix expressions; in particular, once an abstract syntax tree has been constructed, the corresponding postfix expression is given by a simple post-order traversal of that tree.
See: http://en.wikipedia.org/wiki/Tree_traversal
Traversal
Compared to linear data structures like linked lists and one dimensional arrays, which have only one logical means of traversal, tree structures can be traversed in many different ways.

Possible ways of passing binary tree:

There are 6 ways:
VLR - pre-order (Ɓukasiewicz),
LVR - in-order,
LRV - post-order (RPN),
VRL,
RVL,
RLV,

where :
V - Visit node,
L - go Left,
R - goRight.
It is interesting to see mathematical expressions in all six ways.
-but, why I have not yet done - it's a question!
----------------------
for the question - I can't give a respond - it all depends on the implementation details

quuba
Posting Pro
573 posts since Nov 2008
Reputation Points: 123
Solved Threads: 106
 

[can you give the code to convert infix to postfix expression]
lucky_username

lucky_Username
Newbie Poster
1 post since Feb 2011
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: