I'm doing a homework assignment where I'm supposed to look at trees to find the expression, and build my own trees based on expressions, but I'm a little confused about how negative numbers are used. The first problem on the assignment is to find the expression for this tree:
To me, this looks like a poorly made tree, since if you use in-order traversal, you end up with this: X*(50/y)-*(z-36)
. Does that negative sign mean that the entire left branch is negative, like this?: -(x*(50/y))*(z-36)
.
It seems to me that it should be done like this:
The expression here is (–(50*x)+y)/z
, and it reads correctly with in-order traversal. Am I correct in thinking that my professor is wrong here?
Edit: I also have a question about another one of the trees made by my professor. This is the tree:
I'm not sure what the extra + sign means on the far right side. It looks like the answer is (x-(y*80))-((z+4)+20), but since there are two plus signs, I'm not sure what the second one is supposed to do.