Question
write code in python 3 question: To further expedite the flow of traffic on a specific runway, an Air Traffic Control Station monitors aircraft, already
write code in python 3
question:
To further expedite the flow of traffic on a specific runway, an Air Traffic Control Station monitors aircraft, already in flight, to determine their best landing order for the runway.
There exists a priority queue which holds the sequence of aircrafts for landing. The personnels in the station associate each aircraft with a string , for the ID, and an integer , to indicate how criticaly low the fuel level of the aircraft is. The queue is organized in ascending order according to this fuel level.
At the head of the priority queue is the aircraft with the lowest fuel, which means it should land first before any other aircraft in queue. When it has landed it is removed from the head; leaving the subsequent aircraft with the lowest fuel as the new head. When a new aircraft is added to the priority queue, its information is inserted into the proper position so that the overall order of the priority queue is maintained.
number of commands will be given, where the command can be either of the following:
1. add a f - arrival of the aircraft with a fuel level ,
2. land - landing of the aircraft with lowest fuel level.
Complete the following starter code below that uses the Priority Queue data structure to organize the aircrafts added to the queue. And after each land command, print the ID of the aircraft that has landed.
Input Format
First line contains the integer: c - the number of commands.
For the next lines, each line contains either commands:
1. add a f - arrival of the aircraft with a fuel level ,
2. land - landing of aircraft with lowest fuel level.
For each aircraft, is a unique alphanumeric string.
Output Format
After each land command, print the ID of the aircraft that has landed on a line.
Sample Input 0
10
add a1j 3
add b2y 2
land
add c3z 5
land
add d4t 4
add e5e 1
add f6l 10
land
add g7o 21
Sample Output 0
b2y
a1j
e5e
Explanation 0
There are commands. At the beginning, the priority queue is empty:
_
The for the first two commands, aircrafts and are added to the priority queue with their respective fuel level. The priority queue now looks like:
(2,b2y) (3,a1j)
The third command is to land the aircraft with the lowest fuel level; which is . So this aircraft is removed from the queue and its ID, b2y, is printed.
For the fourth and fifth command next c3z is added to the priority queue. And the aircraft has landed, since it has the lowest fuel, and its ID a1j is printed. The priority queue now looks like:
(5,c3z)
For the next sixth to eighth, aircrafts are added to the priority queue; which now looks like:
(1,e5e) (4,d4t) (5,c3z) (10,f61)
The next aircraft to land will be , so its ID e5e is printed.
The last command is to add to the priority queue; which now looks like:
(4,d4t) (5,c3z) (10,f61) (21,g7o)
# Complete the mkAircraft function below.
def mkAircraft(iD, fuelLvl):
# Complete the getiD function below.
def getiD(node):
# Complete the getFuelLvl function below.
def getFuelLvl(node):
# Complete the mkPriorityQueue function below.
def mkPriorityQueue():
# Complete the getContents function below.
def getContents(priQueue):
# Complete the isPriQueueEmpty function below.
def isPriQueueEmpty(priqContents):
# Complete the getPos function below.
def getPos(aircraft, priqContents):
# Complete the addAirCraftToQueue function below.
def addAirCraftToQueue(priQueue, aircraft):
# Complete the popAirCraftFromQueue function below.
def popAirCraftFromQueue(priQueue):
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started