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.

6 Years
Discussion Span
Last Post by lucky_Username

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??


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.


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),

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

Edited by quuba: last line+

This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.