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:

double sio = 5.0;
double gasceng = 5.0;
double i = 1.0;
int en = 8;
int asmshes = 3;

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

2 - 6 - sio + 6 - gasceng + (i % en * 4 * 0 - asmshes % 1) * 4

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean sqixbos = true;
boolean a = true;
boolean uzo = false;
int grihe = 5;
boolean ec = false;
double cew = 1.0;
int thiarspo = 3;
int acwaen = 4;
int phosqee = 6;
int pruped = 2;

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

sqixbos != a != uzo && 0 >= 1 != grihe <= 0 && 6 >= 5 && ec && cew == thiarspo != 0 >= 1 && 5 == acwaen && phosqee >= pruped

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 + 11 + 12

Solution

Things to double-check in your solution:


Related puzzles: