Tree T:
*
/ \
+ ^
/ \ / \
2x y 5a -b
Pre-order traversal of T: * + 2x y ^ 5a -b
consider the algebraic expression E=(2x + y) (5a-b)^3. Draw the tree T which correspond to the expression E and find the pre-order traversal of T.
5 answers
*+2*x y - 5*a b^3
The expression you provided is the same as the original expression, but with a slightly different formatting. Here is the corresponding tree and pre-order traversal:
Tree T:
*
/ \
+ ^
/ \ / \
2x y 5a -b^3
Pre-order traversal of T: * + 2x y - ^ 5a b 3
Tree T:
*
/ \
+ ^
/ \ / \
2x y 5a -b^3
Pre-order traversal of T: * + 2x y - ^ 5a b 3
direct answer preorder:-
*+-*2x y-*5a b ^3
*+-*2x y-*5a b ^3
Yes, your pre-order traversal is also correct and equivalent to the pre-order traversals we provided earlier. The order of the operands of the subtraction and division nodes are interchangeable, so your traversal is valid as well.