1. ## data structures (postfix/prefix)

Hi...

I'm having a few problems with the book that I
have regarding prefix and postfix portion of
data structures. I was wondering if anyone knew
of a web site that might have a few examples that
I could learn from.

Maybe someone can tell me if I'm right or wrong:

prob: Translate each of the following expressions from prefix to postfix:

a) / + x y ! n (prefix)

x y + / n ! (my answer in postfix)

b) / + ! x y n (prefix)

x y + / n ! (my answer in postfix)

These are my results, I'm just looking to see if I am doing this right.

2. I was wondering if anyone knew
of a web site that might have a few examples that
I could learn from.
You could try here.

3. I like to think of it this way...

/ + x y ! n

This is a postfix expression. We can treat each of the operators as a function really....
/(a,b) returns a/b
+(a,b) returns a + b
!(a) returns !n
...
/(+xy, !n)
/(+(x,y),!(n))
And to change it to postfix, we just have to move the operators to the other side of their parenthesis...
(a,b)/ returns a/b
(a, b)+ returns a + b
(a)! returns !a
...
/(+(x, y), !(n))
becomes...
((x, y)+, (n)!)/
x y + n ! /

The hardest part is just realising which variables go to which operators...
/ + ! x y n
/ (+ (!(x), y), n)
(((x)!, y)+, n)/
x ! y + n /

4. ## try this

hi there,
in terms of tree notations,
postfix == left,right,root
prefix == root,left,right
infix == left,root,right

first create the tree of infix form and then go for prefix and postfix notations...........