Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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):

image text in transcribedimage text in transcribed
Runway Traffic Control Problem Submissions Leaderboard Discussions 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. Contest ends in a day There exists a priority queue which holds the sequence of aircrafts for landing. The Submissions: 248 personnels in the station associate each aircraft with a string a, for the ID, and an integer Max Score: 10 f. to indicate how criticaly low the fuel level of the aircraft is. The queue is organized in Difficulty: Easy ascending order according to this fuel level. Rate This Challenge: 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 More 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. cnumber of commands will be given, where the ll command can be either of the following: 1. add a f - arrival of the aircraft a with a fuel level f. 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 c lines, each of line contains either commands 1. add a f - arrival of the aircraft a with a fuel level f. 2. Land . landing of aircraft with lowest fuel level. Constraints 1ges 10 1 5 / $ 1000 For each aircraft, a 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 alj 1 add by 2 Land add C32 5 Land and d4: 4 add fe I Land add To 21 Sample Output 0 bay Explanation 0 There are 1ill commands At the berinning. the priority meue is emptyExplanation 9 There are 10 commands. At the beginning, the priority queue is empty The for the first two commands, aircrafts aly and May are added to the priority queue with their respective fuel level. The priority queue now looks like (2.bay) The third command in to land the aircraft with the lowest fuel level which in May So this aircraft is removed from the queue and its ID, bay. is printed. For the fourth and fifth command next ciz is added to the priority queue. And the aircraft aly has landed, since it has the lowest fuel, and its ID alj is printed. The priority queue now looks lines (5.c3x]] For the next sixth to eighth aircrafts are added to the priority qu which now looks like: (1.ese) [4,d40) (5.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions