How to convert postfix arithmetic expression into prefix arithmetic expression and vice versa?

can someone tell me how to find the algorithm and the code plz?

Printable View

- 02-17-2009, 06:40 PMsfe23Postfix into prefix and vice versa
How to convert postfix arithmetic expression into prefix arithmetic expression and vice versa?

can someone tell me how to find the algorithm and the code plz? - 02-18-2009, 07:38 PMpaul pasciakAll roads lead to Polish Notation
I don't recall the details of postfix or prefit.

When I think about it, I can't imagine the

data structure changing at all. In both

cases you will have a stack with values,

and a stack with operations.

The key is the algorithm that interprets the

stack data.

(I hope someone corrects me on this if I'm

wrong.)

Look up the algorithm for Polish Notaion

in a data structure text. The postfix and

prefix algorithms are probably at the

beginning of that chapter. - 02-19-2009, 04:37 AMsfe23
Thanks for your answer.

I already know what postfix and prefix are.

I need to come up with an algorithm convering postfix to prefix and vice-versa!

how can I do that? - 02-19-2009, 04:54 AMFubarable
There are many posted on the web. I have found such in the past easily with a Google search. Most aren't a Java code conversion but it's not hard to convert from one code to another for this.

- 02-19-2009, 05:40 AMsfe23
I have searched the web but could not find any!

I must have looked at 100 pages already!

when it comes to converting postfix to infix or vice-vera, they give the algorithm or the code using trees and not stack!

I appreciate it if you give me a website if you already know of it.

thanks - 02-19-2009, 05:41 AMsfe23
programmerassist.com/question/93 is one in Java but I do not understand it at all!!! :(

- 02-19-2009, 05:42 AMFubarable
It's been a while since I looked, sorry. Best of luck though.

- 02-19-2009, 05:45 AMsfe23
ahh.. too bad.

- 02-19-2009, 05:49 AMFubarable
Wait, here's one I bookmarked:

Postfix Notation Mini-Lecture - 02-19-2009, 10:37 PMsfe23
Fubarable, thanks for the link.

But I already know the algorithm converting from infix to postfix or infix to prefix.

My concern is postfix to prefix and prefix to postfix using stacks.

:)