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 iin request has a maximum waiting time de-
noted by wait i. That is, if the iin 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 1* request is processed first, and
the n* 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 t, it will be counted for that instant and is
removed at the next instant.
The first request is processed at time =0. A request expires without being pro-
cessed when time = wait i. It must be processed while time wait i. See the ex-
ample below for wait[3].
The initial queue represents all requests at time =0 in the order they must be pro-
cessed.
placed sequentially in a queue, where the i i n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!