Expression Evaluation (10 points) Evaluate the following expressions assuming 32
ID: 3593438 • Letter: E
Question
Expression Evaluation (10 points) Evaluate the following expressions assuming 32 bit integers and 32 bit pointers. Variables are declared as listed but after some unknown number of operations the current state of the memory is given by the supplied memory diagram. 3. struct node int data; struct node* other typedef struct node Node; Node v Node p Variable Name/ Memory Value Address 8000 8004 9000 8008 9004 p 8012 9028 8016 9032 8020 9020 V 9000 42 9004 9016 9008 5 9012 100 9016 87 9020 9008 9024 101 9028 1 9032 8000 9036 9016 a. v.data b. v.other->data; c. p->other->data; d. p->other[2]->data; e. p->other->other->other->dataExplanation / Answer
a. v.data; - 3 [v is the node starting at address 8000, which has a value of 3]
b. v.other->data; - 42 [v.other points location 9000, the data at 9000 is 42]
c. p->other->data; - 1 [ the node p points at location 9028, the data value at 9028 is 1]
d. p->other[2]->; - 87 [ the node p points at location 9028, it's other points to 8000, now we look for the second position in the array, which is 8008 which points to location 9004; which in turn points to 9016; the location 9016 contains the value 87]
e. p->other->other->other->data; - 87 [ the node p points at location 9028, it's other points to 8000, the other of 8000 points to 9000, the other of this location points to 9016, the value at 9016 is 87]
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.