Question
Java program that implements a tree using linked lists. Description: An International Airport administration asked you to develop a scheduling system through which flight arrivals
Java program that implements a tree using linked lists.
Description:
An International Airport administration asked you to develop a scheduling system through which flight arrivals are synchronized among the arriving flights. Each flight sends a request for future landing in the airport specifying the time T of its arrival. To avoid collides, the system should maintain a certain time delay k before and after each flight. Thus, the time T is added to the set of scheduled flights if no other flights are scheduled within k minutes before or after the time T. Otherwise, the system is expected to raise an error and refrain from scheduling the flight. If the flight has landed, it is removed from the schedule list. Any request for a past time is rejected.
To have an efficient system, it is required to utilize a data structure that maintains a sorted list and can provide fast insertion, deletion, and the within k minutes checking. In particular, the goal is to run the system in O(log n) on average. A new schedule is created every day for the flight requests on that day. The delay value k varies every day based on the weather condition. The default value is 3 minutes.
Use a Binary Search Tree (BST) to store the flight details. The tree has the flight time T as a key that the flights are sorted and stored according to their value. Each tree node (flight) should have the following information:
- The flight time T (the key)
- The parent node
- The left child node
- The right child node
- The airlines
- The flight numbers
The system is expected to do the following operations:
- Insertion: Insert a flight in the BST according to the flight time T. You can do the within k minutes check during insertion along with the path from the root to the correct position to add the flight. If you find a flight that is less than the k minutes delay from the time T to be inserted (before or after it), the insertion is interrupted, and proper notification should be sent.
- Deletion: Remove the flight after arrival. This requires finding the flight with the minimum arrival time T and removing it from the list. The tree should be rearranged after deletion to maintain it as a BST.
- Displaying the schedule: print the daily arrival schedule of the flights ordered by their arrival times T.
- Searching: find a flight detail based on its arrival time T.
please write excessive comments explaining the code. thank you.
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