0% found this document useful (0 votes)
4 views

parse tree

The document analyzes various mathematical expressions, detailing their evaluation order based on operator precedence. It includes examples of right-sided and left-sided binding, along with parse trees for each expression. Key evaluations include exponentiation, division, addition, and the use of unary operators.

Uploaded by

Irold Sanchez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

parse tree

The document analyzes various mathematical expressions, detailing their evaluation order based on operator precedence. It includes examples of right-sided and left-sided binding, along with parse trees for each expression. Key evaluations include exponentiation, division, addition, and the use of unary operators.

Uploaded by

Irold Sanchez
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Irold Jerald A.

Sanchez

Analysis:

1. 2 ** 3 ** 2
 Right-sided binding (exponentiation operator).
 Evaluated as 2 ** (3 ** 2) = 2 ** 9 = 512.
2. 10 / 2 * 3
 Left-sided binding.
 Evaluated as (10 / 2) * 3 = 5 * 3 = 15.
3. 5 + 3 - 2
 Left-sided binding.
 Evaluated as (5 + 3) - 2 = 8 - 2 = 6.
4. 8 % 3 * 2
 Left-sided binding.
 Evaluated as (8 % 3) * 2 = 2 * 2 = 4.
5. -4 ** 2
 Right-sided binding (unary operator binds more strongly).
 Evaluated as -(4 ** 2) = -16.
Parse Trees:

1. Expression: 2 ** 3 ** 2 4. Expression: 8 % 3 * 2

**
/ \ *
2 ** /\
/ \ % 2
3 2 /\
2. Expression: 10 / 2 * 3
8 3
*
/ \
/ 3 5. Expression: - 4 ** 2

/
-
/
\
10 2
**
3. Expression: 5 + 3 - 2
/ \
-
4 2
/\
+ 2
/\
5 3

You might also like