August
1999 QUESTION 4 Total Marks: 20 Marks |
Click here to access other
questions
SUGGESTED SOLUTIONS |
You are
to implement an Air Traffic Control queueing system. When a flight reaches the airport, it
receives a landing_number which identifies its position in the landing queue. The
following data type is used to represent the landing queue: TYPE airline = (BritishAirways, SingaporeAirlines, KLM, Lufthansa);
In QueueType, front points to the first aeroplane in the queue and rear points to the last aeroplane in the queue. The Next field of a node points from the older aeroplane in the queue to the newer aeroplane. In addition to this, it is also needed to know how much fuel an aeroplane has left, in case it is about to run out, and this airtime_left is measured in minutes.
|
||
(a) | Write a function, the prototype of
which is given below, which takes the landing queue and removes and returns the oldest
aeroplane in the landing queue (the one at the front). FUNCTION LandPlane (VAR queue: QueueType) : aeroplane; |
[4] |
A
sample definition of a function LandPlane follows: FUNCTION LandPlane(VAR queue: QueueType): aeroplane
|
||
(b) | Write a function the
prototype of which is given below, that returns the landing_number of the aeroplane with
the least fuel left in the queue (i.e., the least airtime left). If there are no
aeroplanes in the queue, the function should return 0. FUNCTION LeastFuelLeft(queue: QueueType) : Integer; |
[6] |
A
sample definition of LeastFuelLeft follows: FUNCTION LeastFuelLeft(queue: QueueType) : Integer
|
||
(c) | A takeoff queue is
represented by the same QueueType, where airtimeleft represents time remaining until
takeoff; and landing_number represents the place in the takeoff queue. Implement the procedure TakeOffPlane, which takes the takeoff queue
and an aeroplanes details, and adds it to the takeoff queue. Note that you will need to
calculate the landing_number for the aeroplane, by adding one to the landing number of the
oldest aeroplane in the queue. |
[6] |
A
sample definition of TakeOffPlane follows: PROCEDURE TakeOffPlane(VAR queue : QueueType, NewPlane:
aeroplane,
TimeToTakeOff: Integer)
New(NewNode);
IF(queue.^rear <> NIL) THEN
|
||
(d) | Write a function
called CoordinateQueue, which will take 3 arguments: the landing queue, the takeoff queue
and a time in minutes. The function should land the oldest aeroplane in the queue, and set it up for takeoff in the takeoff queue, with the time parameter specifying the time in minutes until the plane is expected to take off. The function will return TRUE if there has been a place to land and schedule for takeoff, and FALSE otherwise. |
[4] |
A
sample definition of CoordinateQueues follows: FUNCTION CoordinateQueues(VAR LandingQueue : QueueType,
VAR TakeOffQueue : QueueType, Time: Integer) : BOOLEAN
|