Question: placed sequentially in a queue, where the i i n request has a maximum waiting time de - noted by wait i . That is
placed sequentially in a queue, where the request has a maximum waiting time de
noted by wait That is if the request is not served within wait i seconds, then the
request expires and it is removed from the queue. The server processes the request
following the First In First Out FIFO principle. The request is processed first, and
the request is served last. At each second, the first request in the queue is pro
cessed. At the next second, the processed request and any expired requests are re
moved from the queue.
Given the maximum waiting time of each request denoted by the array wait, find the
number of requests present in the queue at every second until it is empty.
Note:
If a request is served at some time instant it will be counted for that instant and is
removed at the next instant.
The first request is processed at time A request expires without being pro
cessed when time wait It must be processed while time wait See the ex
ample below for wait
The initial queue represents all requests at time in the order they must be pro
cessed.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
