1.0110 Given the following section of code:
struct studinfo { char studentname[25];
int age, credithours;
float gpa;
struct studinfo
*next, *previous; };
/* next points to the next record in the linked list;
previous points to the previous
record in the linked list */
struct studinfo
*head, *present, student[5] = {{“Shakespeare,
Bill”,256,12,3.56,NULL,NULL},
{“Albee,
Edward”,76,120,2.78,NULL,NULL},{“Voltaire”,56,82,3.75,NULL,NULL},
{“Chaucer,
Geoffry”,420,91,3.25,NULL,NULL}, {“Grisham, John”,46,24,1.57,NULL,NULL}} ;
// head will point to the
first record in the list after it is linked by studentname in ascending order
For the following questions,
assume that I have developed a list which is linked (the code necessary is NOT
shown), in ascending order, on student[].studentname.
Assume that the base address (in RAM) for the database (for student; NOT the linked list) is 4000.
sizeof(struct studinfo) = 25 + 2 + 2 + 4 + 2 +
2 = 37
address
name age chrs gpa next previous
====== ============= === === === ==== =======
4000 Shakespeare,
Bill 256 12 3.56 4074
4148
4037 Albee,
Edward 76 120 2.78 4111 NULL
4074 Voltaire 56 82 3.75 NULL
4000
4111 Chaucer,
Geoffry 420 91 3.25 4148 4037
4148 Grisham,
John 46 24 1.57 4000 4111
For the following questions,
assume that I have developed a list which is linked (the code necessary is NOT
shown), in ascending order, on student[].studentname.
Assume that the base address (in RAM) for the database (for student; NOT the linked list) is 4000.
a. What is the value of head (after the links are complete)? 4037
b. What is
the value of &student[3]? 4111
c. What the
value of student[0].next? 4074
d. What is
the value of student[2].previous -> gpa? 3.56
e What is
the value of student[4].next -> studentname? Shakespeare
f. What is
the value of student[3].previous -> previous? NULL
g. given present = student[0].next; what is the
value of --present? 4037
h. What would be the value of student[2].next AFTER the command
student[2].next = (struct
studinfo *) malloc(sizeof(struct studinfo));? Unknown
i. Explain
your answer to the above question Memory is allocated at run time
j. Explain
how I would remove Albee, Edward
from the LINKED list.
Set head pointer to Chaucer and have
chaucer.previous point to NULL