Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Assume that we have the following declarations: type SList = record N: integer;

ID: 3837218 • Letter: A

Question

Assume that we have the following declarations:

     type SList = record

          N: integer;

          Next: SList

          end;

     var q,r,s : SList;

          T: SList;

Assume that the situation diagrammed below exists before each part of this problem:

Boxes with two slots are SLists. The top slot is the N field; the bottom is the Next field. Reference values are arrows; nil appears as a ground symbol. Undefined values are blank. For named variables, each name appears above the upper left corner. Write sequences of assignments that convert the situation diagrammed above to each of the configurations (a-g) below:

I have done (a) and (b) as examples

(a) T.N := 6; T.Next := nil;

(b) q.Next.Next := nil;

4

Explanation / Answer

a. T.N = 6; T.next = null;

b. q->next->next = null;

c. s->next = T;

d. s->N = 5; s = r;

e. q = q->next;

f. r = q->next;

g. T.N = 6; T.next = null; r->next = s; s->next = T;