CIS3355:
Data Structures
The
1.0010 List all the advantages and disadvantages of
singly linked list. Of doubly linked lists?
1.0050 I have five books which I have listed in a
spreadsheet as follows:
Title |
Author |
Year Written |
Value |
Tolstoy |
1876 |
125 |
|
Great Gadsby, The |
Fitzgerald,
F.S. |
1932 |
50 |
Guliver’s Travels |
Swift |
1726 |
250 |
Rhetoric |
Aristotle |
329 BC |
1500 |
Vanity
Fair |
Thackeray |
1847 |
750 |
a. Set up the needed structure
template (call it struct booktemplate)
to link the list alphabetically by author (make up string lengths as you see
fit).
b. Assign the variable book
to the structure template. Show the declarations necessary.
c. Assume that the base address of the variable book is 9000. Set up a table which would
show all of the linkages.
d. Now link the list by year written and value (maintaining the
linkages established above). Show the modified struct booktemplate. Assuming that the base
address of books remains 9000, show
(in tabular form) how the linkages would appear.
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
a. What is the value of head (after the links are complete)?
b. What is the value of &student[3]?
c. What the value of student[0].next?
d. What is the value of student[2].previous -> gpa?
e. What is the value of student[4].next -> studentname?
f. What is the value of student[3].previous -> previous?
g. given present
= student[0].next; what is the value of --present?
h. What would be the value of student[2].next AFTER the command
student[2].next = (struct studinfo *) malloc(sizeof(struct studinfo));?
i. Explain your answer to the above question
1.0120 Given
the following section of code:
struct studinfo
{ char studentname[30];
struct studinfo *nextgpa;
short age, credithours;
long weightindrams;
float gpa; };
// nextage points
to the next record in the linked list in terms of age
struct studinfo *head,
*present, student[6] = {{“Christie,
Agatha”,, 96, 82, 37324, 3.05},
{“Shakespeare, Bill”,,
256,12, 52253, 3.56}, {“Albee, Edward”,, 76, 120,
72689, 2.78},
{“Voltaire”,, 56, 82, 64766, 3.75,}, {“Chaucer, Geoffry”,, 420, 91, 41566, 3.25},
{“Grisham, John”,,
46, 24, 66456, 1.57}} ;
// head will point to the first record in
the list after it is linked by gpa in ascending (lowest to
// highest)
order and present will be used to
point to a record.
For the
following questions, assume that I have developed a list which is linked (the
code necessary is NOT shown), in ascending (lowest to highest) order, on student[].gpa.
The
command: printf(“%lu\n”,&student[3].weightindrams);
yields the output: 7686
1. What
is the value of head (after the links are complete)?
___________________
2. What
is the value of &head (after the links are complete)? __________________
3. What is the value of &student[4]? _____________________________________
4. What the value of student[0].nextgpa? _________________________________
5. What is the value of student[2].nextgpa-> weightindrams? ________________
6 What is the value of student[4].nextgpa ->
studentname? _________________
7. If present
= student[3].nextgpa;
what is the
value of ++present ???
_____________________________________
8. If present
= student[0].nextgpa;
what is the
value of present -> nextgpa ->nextgpa ->credithours ? __________