Question
In the school computer room a set of servers is responsible for processing all computing tasks, each one with its own time cost. In order
In the school computer room a set of servers is responsible for processing all computing tasks, each one with its own time cost. In order to balance the time load for each server, it is necessary to assign all tasks to make the dierence between the most loaded server and the least loaded server as small as possible. In other words it is necessary to minimize the expression tmaxtmin , where tmax (tmin) is the largest (smallest) sum of the running times of all tasks assigned to a server. Write the function: void balance (int nTask, int *times, int nServer); which Receives the number of tasks nTask, the array storing the time costs of all tasks times, and the number of servers nServer in the computer room. Assigns each task to a server such that the aforementioned cost function is minimized. The function has to print the computer identier (a number from 0 to nServer1) assigned to each task. For example if there are nTask=7 tasks, with time costs equal to times = {1,2,3,4,5,6,7}, and nServer = 3 servers, we can assign {2,7} to computer 0, {3,6} to computer 1, and {1,4,5} to computer 3, with a cost dierence of 109 = 1.
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