220k views
1 vote
Given the following definitions that we have used in class to represent a doubly-linked, circular List with a dummy-header node that contains data of type "struct Student".

typedef struct { char *name; char *major; } Student;
typedef struct node { Student *data; struct node *next; struct node *prev; } Node;
typedef struct { Node *header; int size; } LinkedList;
LinkedList *roster;
Here is a picture of what the Linked List might look like, although you should answer the following question for a general list (ie, that does not necessarily contain 3 data items).
What TYPE of data is the following: roster->size
1)int
2)* int
3)Node
4)* Node
5)Student
6)* Student
7)char
8)* char
This is legal code, but it does not match any of the types listed above.
This is illegal code, and would produce a syntax error.

1 Answer

2 votes

Final answer:

roster->size is of data type int, representing the number of items in the list.

Step-by-step explanation:

The data type of roster->size in the context of the given LinkedList definition is int. The 'size' field within the LinkedList struct is specifically declared as an integer, which holds the number of items in the list. Hence, when accessing the 'size' field of 'roster', which is a pointer to a LinkedList, we are accessing an integer value that represents the size of the list.

User Ken Tsoi
by
8.0k points