Please explain A major airline decides it wants to board passengers passed on their priority status. The passengers will board the airplane one at a time in a single file order. The higher the priority passenger rating, the earlier they should board (assume there are no ties). What data structure should this airline use? How long will it take to board N passengers in Big-O? Note: We do not know when the passengers will arrive at the gate, but we will always want to allow the passenger with the highest priority to board first. Group of answer choices a. A priority queue is the best data structure. The priority queue uses a max-heap such that passengers with the highest priority will be at the top of the heap. In order to board N passengers, it will take O(nlog(n) time. N removals for each of the passengers and then log(n) time for each removal to rebuild the max-heap structure.
Please explain
A major airline decides it wants to board passengers passed on their priority status. The passengers will board the airplane one at a time in a single file order.
The higher the priority passenger rating, the earlier they should board (assume there are no ties). What data structure should this airline use? How long will it take to board N passengers in Big-O?
Note: We do not know when the passengers will arrive at the gate, but we will always want to allow the passenger with the highest priority to board first.
a. A priority queue is the best data structure. The priority queue uses a max-heap such that passengers with the highest priority will be at the top of the heap.
- In order to board N passengers, it will take O(nlog(n) time.
- N removals for each of the passengers
- and then log(n) time for each removal to rebuild the max-heap structure.
b. A binary search tree is the best data structure. The binary search tree will search for the greatest value in a worse-case of O(n).
In order to board N passengers, it will take O(n*n) time.
- N removals for each of the passengers
- and then O(n) time for each search in the tree
Step by step
Solved in 2 steps