Hi, I received this one type of question from Amazon 2nd round interview and I didn't quite get an answer that passed more than a few test cases. I'd love to know what this type of question requires in terms of data structures/algorthims. Thanks!
loadbalancing question, the function must return an array of integers that denote the id numbers of the servers that did the most work in ascending order
loading balancing following parameters: int k: the number of web servers, int arrival[n]: the arival times of each request, int load[n] the load of each request, ie: the time to serve each request
return int an array of integers that denote the id numbers of the servers that did the most work in ascending order
This was written with C in mind but I used Python
k = 3, n = 5 arrivals = [1, 2, 3, 4, 5], load = [6, 3, 4, 4, 4]
all of the servers start out available. the first 3 requests are handled by the 3 servers in order. when request 4 comes in, server 1 is usy but server 2 is available and serves the quest. requests 5 cannot be served so it is dropped. server 1 handles a load of 6 and server 2 handles a load of 3 + 4 = 7
server 2 was the busiest server
k = 3, arrival = [1, 2, , 12 ,5 ,6 , 30, 32] load = [15, 10, 10, 10 ,10, 15, 10]
return 1, 3
k = 3, arrival = 1, 10, 100. load = 5, 5, 5 return 1,2,3