Results 1 to 2 of 2
Thread: Help with Algorithm to the code!
- 03-02-2009, 02:27 AM #1
Help with Algorithm to the code!
I really am trying to write the code. It has been almost a week that I am working on this and I am really stuck.
I am trying to write a code that converts an infix expression into prefix. i.e. 3+4 becomes + 34. I already have the algorithm and I just simply try to convert that into the code but I need help on the part where I need to compare the current operator with the one on top of the stack as you may see in my comments!!
Below is my code:
Nopaste - No description
I truly appreciate your help since this is a part of a way bigger assignment and if I don't do this part I cannot move on!
Last edited by sfe23; 03-02-2009 at 02:28 AM. Reason: mistake
- 03-03-2009, 01:17 AM #2
what kind of algorithm are you using?
for the record, what i'd did was... reverse the string.
so (A+B)/C becomes: C/(B+A).
then use the shunting-yard algorithm to convert infix 2 postfix, which= CBA+/.
then again, reverse the string, which = /+ABC
(referring to prefix here...)
Last edited by angryboy; 03-03-2009 at 09:38 AM.USE CODE TAGS--> [CODE]...[/CODE]
Get NotePad++ (free)
- By itseeker87 in forum New To JavaReplies: 8Last Post: 09-09-2008, 06:12 PM
- By RLRExtra in forum New To JavaReplies: 6Last Post: 01-17-2008, 05:11 PM
- By susan in forum New To JavaReplies: 1Last Post: 07-13-2007, 11:26 PM
- By Marcus in forum Advanced JavaReplies: 3Last Post: 07-02-2007, 02:30 PM
- By Daniel in forum Advanced JavaReplies: 2Last Post: 07-02-2007, 06:51 AM