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 grawcle = 2.0;
double a = 4.0;
int twearhant = 5;
double siingean = 5.0;
int mamfo = 4;

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

grawcle % (9 * 6 % 7 + 1 - a * twearhant / 1 * 3 + siingean) + 3 / mamfo

Solution

Things to double-check in your solution:


Part 2

Given the following variables:

boolean groho = false;
boolean wresh = false;
double puch = 2.0;
double thi = 5.0;
double binnir = 4.0;
int isnoan = 3;
boolean liechca = true;
boolean dieng = false;
double nas = 2.0;
int riensan = 7;
boolean hi = false;
double asort = 2.0;
double duendo = 4.0;

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

groho && wresh || puch < thi != binnir >= isnoan != !liechca || dieng != nas < riensan && !!hi || 1 >= 4 || 8 <= asort != (duendo == 1)

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: