Drawing ASTs for expressions: Correct Solution


For each of the Java expressions below:

Be sure that your tree accurately reflects how Java would evaluate the expression.

Part 1

Given the following variables:

int stic = 3;
int le = 7;
int eni = 3;
double tibhen = 1.0;
int rer = 5;

...draw the AST and evaluation results for the following expression:

2 * stic * le / 1 / eni + 9 * tibhen % 6 / 5 / rer

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

int luasmoc = 7;
boolean hi = true;
boolean boso = false;
double mithdu = 3.0;
int heounbel = 8;
boolean in = true;
int ee = 6;
int no = 7;
double i = 5.0;
boolean stos = true;

...draw the AST and evaluation results for the following expression:

luasmoc <= 8 || hi && boso && 3 == 7 || !(mithdu != heounbel) && !in != 6 >= ee != no <= i != !stos

Solution

Things to double-check in your solution:


Part 3

Draw the AST and evaluation results for the following expression:

0 + 1 + 2 + (3 + 4 + 5 + 6 + "7" + 8 + 9) + "10"

Solution

Things to double-check in your solution:


Related puzzles: