Airline Gate Queue OverviewAn airline control center tracks aircraft waiting to reach a gate. Each aircraft has a unique integer id and a priority equal to its ETA (in minutes). A smaller ETA means higher dispatch priority. The system supports adding new aircraft (insert), decreasing an aircraft’s ETA (decreaseKey), and dispatching the aircraft with the smallest ETA (extractMin). Data Model• The priority queue is a min-heap stored in an array, using 0-based indexing.• The heap stores nodes directly: each entry is {priority, id}, both integers.• One hash map (key: current index, value: reference to heap array) accompanies the heap to allow decreaseKey to be implemented in O(log n).• Priorities (ETAs) are guaranteed to be unique at all times; the aircraft with the smallest priority is always the one dispatched (no tie-breaking needed). Provided Helpers (assumed present and correct and you don’t need to implement these)• heapify_up(i): restores heap order upward from index i.• heapify_down(i): restores heap order downward from index i. Functions to Implement flight_add(int id, int priority)Purpose: introduces an aircraft with the specified id and initial ETA. Inserts a node {priority, id} into the 0-indexed min-heap and records the heap index for this id. decrease_flight_key(int id, int newPriority)Purpose: updates the priority of the specified aircraft from its current ETA to a strictly smaller ETA. The aircraft remains in the heap; only its priority changes. The effect is that its relative order may improve according to the heap’s ordering by priority. flight_pop() -> intPurpose: removes and returns the id of the aircraft with the smallest ETA (priority) from the min-heap, restoring the heap property afterward. Example flight_add(42,9); flight_add(17,12); flight_add(11,13); decrease_flight_key(11,7); flight_pop(); decrease_flight_key(42,6); flight_pop(); flight_pop(); Expected outputs when calling in order:[11, 42, 17] Structure of the Problem class AirlineGateQueue {public: struct Node { int pr, id; }; vector heap; unordered_map idx; void heapify_up(int i); void heapify_down(int i); void decrease_flight_key(int id, int newPriority); void flight_add(int id, int priority); int flight_pop();}; You can use the following compilers to test your code: 1. https://cpp.sh/2. https://my.newtonschool.co/playgrounds/cpp-compiler3. https://www.w3schools.com/cpp/trycpp.asp?filename=demo_compiler
Blog
In a heap implemented with an array, an item at index 12 has…
In a heap implemented with an array, an item at index 12 has its left child at index [leftchild] and its right child at index [rightchild] and its parent is at index [parent]. The index of the root of the heap is 0.
If fixed costs are $500,000, the unit selling price is $55,…
If fixed costs are $500,000, the unit selling price is $55, and the unit variable costs are $30, the break-even sales (units) if fixed costs are increased by $80,000 is
Rocky Company reports the following data: Sales $800,000…
Rocky Company reports the following data: Sales $800,000 Variable costs 300,000 Fixed costs 120,000 Rocky Company’s operating leverage (rounded to one decimal place) is
Which of the following would be classified as a variable cos…
Which of the following would be classified as a variable cost for a T-shirt manufacturer?
The nurse has provided patient teaching about potassium spar…
The nurse has provided patient teaching about potassium sparing diuretic therapy. Which statement by the patient indicates a need for further teaching?
concepts Which common over-the-counter agent is an antiplate…
concepts Which common over-the-counter agent is an antiplatelet drug?
concepts Which category of drugs actually dissolves existing…
concepts Which category of drugs actually dissolves existing clots?
How does a detergent differ structurally from soap?
How does a detergent differ structurally from soap?
The product from the synthesis of aspirin (see Question 16)…
The product from the synthesis of aspirin (see Question 16) was tested with FeCl3. The test resulted in a purple color. What did the test indicate about the purity of the compound synthesized? If not pure, what could be the contaminate?