GeeksforGeeks » Interview Questions
A software design question
(6 posts)-
A software subsystem of an air-traffic control system is defined to manage a
queue of aircraft (AC) in an airport. The aircraft queue is managed by a pr
ocess which responds to three types of requests:system boot used to start the system.
enqueue aircraft used to insert a new AC into the system.
dequeue aircraft used to remove an AC from the system.
AC’s have at least (but are not limited to having) the following properties
:AC type: Passenger or Cargo
AC size: Small or Large
The process which manages the queue of AC’s satisfies the following:
There is no limit on the number of AC’s it can manage
Dequeue aircraft requests result in selection of one AC for removal such tha
t:Passenger AC’s have removal precedence over Cargo AC’s
Large AC’s of a given type have removal precedence over Small AC’s of the
same type.Earlier enqueued AC’s of a given type and size have precedence over later e
nqueued AC’s of the same type and size. -
1 manages 1 ACManager-------------------->ACQueue /\ 1 \/ | | | | * AC / \ --- | | | ------------------------- | | | | PassangerAC CargoAC -
More explanations please? Is there any design pattern that fits to this problem?
-
ACQueue would have following functions
enQueue() We can have all enqueue logic in this function.
deQueue() We can have all dequeue logic in this function.Not sure about the design pattern that can fit :(
-
We can create array of 4 pointers to lists. There are the lists by their priorities:
1. Large+Passenger (most significant priority)
2. Small+Passenger
3. Large+Cargo
4. Small+Cargo (least significant priority)In enqueue function we push_back to corresponding list (by type and size).
In dequeue function we pop_front from the list with the most significant priority (if it doesn't empty). -
assign priority for 4 types and build a priority queue using max heap
Reply
You must log in to post.