Reputation: 376
I'm having trouble with a question:
Draw the expression tree obtained from the following fully parenthesised algebraic expression:
"( ( ( 4 + ( 9 * 3 ) ) - ( ( 6 * ( 2 + 4 ) ) / 3 ) ) + 1 )"
Write the elements of the expression tree which are at level 4 (the root node is level 0). Write the level four elements left to right, separated by a single space.
So far I have the following expression tree:
-
+ +
4 * / 1
9 3 * 3
6 +
2 4
and then as far as I know the 4th level elements are:
9 3 * 3
but it is wrong. Am I doing something wrong?
Upvotes: 0
Views: 1015
Reputation: 107347
The mistake is in root , so it must be +
with 1
and -
as its childes. attend to your parenthesis !
+
- 1
+ /
4 * * 3
9 3 6 +
2 4
Upvotes: 1