December 1999
AP207 : ADVANCED PROGRAMMING TECHNIQUES

QUESTION 3

Total Marks: 15 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 3

You are to implement a system which will manage patients in a doctor ’s waiting room. When a patient arrives in the waiting room,a record is entered in a queue which contains the patient ’s name,the order number in which they arrived in the waiting room, and their condition,which can take one of the following values: trivial , concerning , or critical . The following data type is used to store this information:

TYPE IllnessCategory = (Trivial, Concerning, Critical);

Patient = RECORD

      Name: String [10 ];
      OrderNumber : INTEGER;
      Condition : IllnessCategory;

END;

TYPE NodePtr = ˆNode;

Node = RECORD

           Next : NodePtr;
           Data : Patient;

            END;

Queue = RECORD

    Front,Rear :NodePtr;

            END;

FUNCTION EmptyQueue(PatientQueue : Queue) : BOOLEAN;

FUNCTION RemovePatient(VAR PatientQueue : Queue) : Patient;

 

(a)

Briefly explain what is meant by a Circular Queue .

 

[2]

(b)

Write a procedure, called AddPatient , the signature of which is given below,which takes a queue of patients and a new patient record, and adds the new record to the patient queue.The order number associated with a given patient is one greater than the order number associated with the previous patient.You may use the standard queue function EmptyQueue ,the signature of which is given above.


PROCEDURE AddPatient(VAR PatientQueue :Queue, Data :
Patient);

 

[6]
(c)

Write a function,called Emergencies ,the signature of which is given below, which will take as a parameter the patient queue, and will return a second queue which contains all of the patients whose conditions are Critical .These patients should be removed from the original queue.You can assume the standard queue function, RemovePatient , which removes and returns the patient at the head of the queue.


FUNCTION Emergencies(VAR PatientQueue : Queue): Queue;

[7]