August 2000
AP207 : ADVANCED PROGRAMMING TECHNIQUES

QUESTION 2

Total Marks: 15 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 2

You are to implement a data structure which can be used to store details of Informatics students. Each student is to be represented by a record, and the system requires to store details of each students name, number and whether or not the student has passed or failed.

(a) Define a simple enumerated data type, called ResultsCategory, which can take on either of the values Pass or Fail. [1 mark]

(b) Define a suitable data structure for a student, called Student, which contains the student’s name - a string of up to 50 characters in length, the student’s identification number, which is an integer, and the student’s result, which is of type ResultsCategory given above. [4 marks]

(c) It has been decided that the complete set of all student details should be held in a double linked list. Give a definition of a double linked list, called StudentList, where nodes in the list consist of a Student structure and pointers to the next and previous nodes in the list.
You may assume that both ends of the list are represented by null pointers. [5 marks]

(d) Define a procedure, called Separate, the signature of which is given below, which takes a StudentList, and references to two other StudentLists. On termination, the procedure should have copied all of the students in the original list with passes into one list, and fails into the other. You may wish to use the standard list manipulation function Add, which takes a list element E and adds it to the list L. You are not required to implement Add.
PROCEDURE Add(Var L : StudentList; Student E);
PROCEDURE Separate(RegisterList : StudentList;
VAR PassList, FailList: StudentList); [5 marks]