Given a gas station with two pumps and a collection of cars

Given a gas station with two pumps, and a collection of cars 1, 2, ..., n with filling time s, for item i (on both pumps). Find a schedule that assigns cars to the two pumps, so that if the first pump is assigned a sum of t_1 and the second a sum of t_2, max{t_1, t_2} is minimum. Note that you only have to decide which car is assigned to pump 1 and which to pump 2, because the order will not change the sum. This will minimize the maximum time that any of the two pumps are \'\'busy\", hence it is of benefit for the gas station.

Solution

Start
boolean pump_1=false, pump_2=flase
int queuePump_1=0, queuePump_2=0;
while(cars are coming)
{
if(!pump_1)
queuePump_1++;
}
else if(!pump_2)
queuePump_2++;
else
if (queuePump_1<=queuePump_2))
{
queuePump_1++;
}
else
{
queuePump_2+++;
}
The above given pseudo code will do the job of allocating the resource (pump) in such a manner both the pumps will be utilized efficiently to minimize
the time taken by the pump station to fuel the cars.

 Given a gas station with two pumps, and a collection of cars 1, 2, ..., n with filling time s, for item i (on both pumps). Find a schedule that assigns cars to

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site