# Could somebody check my binary tree?

• 11-28-2012, 07:55 PM
sim18
Could somebody check my binary tree?
could somebody please tell me what (A*B) / (C^D^E) is in POST ORDER.

I drew the tree and went back over it in post order

Code:

```        /   *      ^  A  B  C  ^             D  E```
From this I get :

AB*C/D^E^, is this correct?
• 11-28-2012, 08:08 PM
KevinWorkman
Re: Could somebody check my binary tree?
First off, define exactly what you mean by post order.

I might point out that AB*C/D^E^ isn't a valid expression.
• 11-28-2012, 08:15 PM
eRaaaa
Re: Could somebody check my binary tree?
Tree traversal - Wikipedia, the free encyclopedia

To traverse a non-empty binary tree in postorder, perform the following operations recursively at each node[1]:
Traverse the left subtree.
Traverse the right subtree.
Visit the root.

@Kevin: I think the "right" postorder traversation will generate a non "valid expression" too....
• 11-28-2012, 08:21 PM
KevinWorkman
Re: Could somebody check my binary tree?
Quote:

Originally Posted by eRaaaa
@Kevin: I think the "right" postorder traversation will generate a non "valid expression" too....

Good point!
• 11-28-2012, 08:36 PM
JosAH
Re: Could somebody check my binary tree?
The correct postfix expression (according to your tree) is: AB*CDE^^/

kind regards,

Jos
• 11-28-2012, 08:39 PM
JosAH
Re: Could somebody check my binary tree?
Quote:

Originally Posted by KevinWorkman
I might point out that AB*C/D^E^ isn't a valid expression.

Yes it is: it has five operands and four binary operators and the evaluation stack is never empty in between ...

kind regards,

Jos
• 11-28-2012, 09:11 PM
sim18
Re: Could somebody check my binary tree?
Thank you very much