Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are some processes that need to be executed. Amount of a load that process causes on a server that runs it, is being represented

There are some processes that need to be executed. Amount of a load that process causes on a server that runs it, is being represented by a single integer. Total load caused on a server is the sum of the loads of all the processes that run on that server. You have at your disposal two servers, on which mentioned processes can be run, Your goal is to distribute given processes between those two servers in the way that, absolute difference of their loads will be minimized. Write a function: class solution { public int solution(int[] A); } (JAVA) that, given an array of A of N integers, of which represents loads caused by successive processes, the function should return the minimum absolute difference of server loads. For example, given array A such that:

A[0] = 1

A[1] = 2

A[2] = 3

A[3] = 4

A[4] = 5

Your function should return 1. We can distribute the processes with loads 1,2,3,4 to the first server and 3,5 to the second one, so that their total loads will be 7 and 8, respectively, and the difference of their loads will be equal to 1.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Big Data 29th British National Conference On Databases Bncod 2013 Oxford Uk July 2013 Proceedings Lncs 7968

Authors: Dan Olteanu ,Georg Gottlob ,Christian Schallhart

2013th Edition

3642394663, 978-3642394669

More Books

Students also viewed these Databases questions