0% found this document useful (0 votes)
19 views2 pages

Assignment 02

Uploaded by

dexejo8791
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Assignment 02

Uploaded by

dexejo8791
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

University of Home Economics, Lahore

Department of Computer Science & Information Technology

Assignment 02

DEADLINE: 6th December, 2024


COURSE: Data Structures
Instructor: SameenFatima

Airport Simulation Problem

The airport simulator is a turn based simulator. Within each turn a number of events, specified
below, occur. A clock (an integer) is kept to track the number of turns. Each turn takes one clock
tick. Your simulator needs to determine which planes land and take off at each turn.
A plane may be sitting on the ground waiting to take off or a plane may be in the air waiting to
land. The planes in the air have a nonnegative integer amount of fuel. During each turn the fuel
of each in air plane is reduced by one. Once a plane in the air reaches zero fuel that plane must
land before the next turn or that plane will crash. This allows planes to land in priority order
(zero fuel has highest priority, 1 unit has the next priority, etc.).

A non-priority queue must be used to track planes waiting to take off. Planes take off in the order
in which they entered the system.

The airport has one runway. During each turn, runway lands exactly one plane or allows exactly
one plane to take off. Runway may not both land and launch a plane in the same turn. Runway
may also sit idle for a turn if no plane needs to land or take off.

The clock starts at 1.

A turn includes the following events in the following order:


1. Read a line of data from the file “airport.txt”. Each line describes airplanes that are joining
the take off queue and landing queue. Further, the amount of fuel on board for each newly
arrived “need to land” plane is provided. Each plane arrives with a positive, non zero integer
amount of fuel. No fuel is assigned to planes that need to take off.
2. Enter the new planes into their appropriate data structures.
3. Decrement each “need to land” plane’s fuel by 1.
4. Those planes that “need to land” with a fuel value of zero must be assigned runways for
landing.
5. Service (land or take off) the plane at the head of the larger queue and remove that plane
from its queue. If the queues are the same size, land a plane.
6. Print the results for the events of this turn.
7. Increment the clock by 1.
8. Return to step 1. Stop the simulation when both the file is executed and both queues are
empty.
University of Home Economics, Lahore
Department of Computer Science & Information Technology

Data File

The data file is guaranteed to not be corrupt or invalid. Zeros in various spots are valid. Airplane
crashes do not mean your simulation is not working. If your airport simulator crashes that is an
entirely different story.

Each line in the data file contains the following integers, separated by a single space, in this
order:

Number Of New Planes That Want To


Takeoff Number Of New Planes That Want
To Land
The amount of fuel on board for new landing plane 1
The amount of fuel on board for new landing plane 2

The amount of fuel is zero if there is no plane in that position.


3 2 1 1
3 2 2 2
0 0 0 0
2 1 7 0
2 1 6 0
2 2 2 9
3 2 1 5
2 2 1 2
1 0 0 0

You might also like