August
1999 QUESTION 2 Total Marks: 20 Marks |
Click here to access other
questions
SUGGESTED SOLUTIONS |
You are to implement
a student record database system for an Information Technology course. The system stores
one record per student per course. There are four different subjects on the course :
C programming (denoted by CA), Pascal Programming (denoted by AP), C++ programming
(denoted by CPP) and Java programming (denoted by JPP).
|
||
(a) | Define a suitable enumerated type type, subject_type, which takes on the value of any of the four subject types denoted. | [1] |
enum subject_type {CA,
AP, CPP, JPP};
|
||
(b) | Declare a suitable data structure
StudentRecord, for each student, which is capable of holding the following information:
|
[5] |
A sample definition of
student_record follows: typedef
struct student_record{
|
||
(c) | Given the definition of the double linked list
which you are to use for storing your records : typedef
struct { Write a function |
[4] |
A sample of definition
of add_candidate follows: void
add_candidate(double_linked_list* mylist, StudentRecord* candidate)
|
||
(d) | Write a function StudentRecord* remove_candidate(int mark); that will take in the value of a mark, and remove and return the first occurrence in the list that it finds of a candidate scoring that mark. If no candidate is found scoring that mark, the function will return NULL. | [6] |
A sample of definition
of remove_candidate follows: StudentRecord*
remove_candidate(int mark)
while(iterator->right!=NULL) {
|
||
(e) | Write a function sort_list, that takes a pointer to the list x, and a pointer to an empty list y, and, starting at the maximum mark of 60 and decreasing to the minimum mark of 0, will perform a sort. Each element matching the current mark should be removed from the original list, and added to the new list. The result will be that the list y will contain all of the records which were in x, but in decreasing order of marks. | [4] |
A sample of definition of sort_list follows: void
sort_list(double_linked_list *x, double_linked_list *y) for(count
= 60; count >=0; count--) {
|