April 2000
AP207 : ADVANCED PROGRAMMING TECHNIQUES

QUESTION 5

Total Marks: 15 Marks

Click here to access other questions

Click to access
SUGGESTED SOLUTIONS
for Question 5

When an aeroplane approaches a certain airport,a record is entered in a queue which contain the right registration number,which is a string of up to ten characters,an arrival number,which si an integer indicating the order in which aeroplanes arrived in the airport, and a landing priority,which can be one of urgent,normal or low.

(a)Briefly explain what i meant by a queue data structure.[2 marks ]

(b)Give a suitable type declaration for the LandingPriority type described above,such that variables of this type can have any one of the values urgent normal or low [1 mark ]

(c)Give a definition of a data tructure called FlightArrival which holds all of the
right details mentioned above.[4 marks ]

(d)Give a definition of a data tructure which can be used to implement a dynamic queue of FlightArrival structures.[3 marks ]

(e)Write a function,called PeekNextLanding the signature of which is given below, which takes a queue q and returns a copy of the first FlightArrival in q which has a urgent landing priority,or the first element in the queue should there not be an element with this priority.You may assume standard queue manipulation routines, and the function should not remove the element from the queue.

FUNCTION PeekNextLanding(q : Queue) : FlightArrival;
[5 marks ]