1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
rusak2 [61]
3 years ago
15

Write a function that, given an array A of N integers, of which represents loads caused by successive processes, the function sh

ould return the minimum absolute difference of server loads.
Computers and Technology
1 answer:
Papessa [141]3 years ago
6 0

Answer:

// here is code in c++.

#include <bits/stdc++.h>

using namespace std;

// main function

int main()

{ // variable to store number of loads

   int n;

   cout<<"enter the number of servers:";

   // read the number of servers

   cin>>n;

   // create an integer array of servers of size n

   int server_load[n];

   // read the load of each server

   cout<<"enter the loads on each server:"<<endl;

   for(int x=0;x<n;x++)

   {

       cin>>server_load[x];

   }

   // sort the array

   sort(server_load,server_load+n);

   int min_diff=MAX_INT;

   // find the minimum absolute difference between the server load

   for(int y=0;y<n-1;y++)

   {

       int d=server_load[y+1]- server_load[y];

       if(d<min_diff)

       min_diff=d;

       

   }

   // print the minimum difference

   cout<<"minimum absolute difference of server load is: "<<min_diff<<endl;

return 0;

}

Explanation:

Read the number of servers from user and assign it to "n".Create an integer Array of size n to store the load on each server.Read the load of each server and store  in the array. Sort the array. Then find the minimum difference between two load of servers. Print the minimum difference.

Output:

enter the number of servers:6                                                                                              

enter the loads on each server:                                                                                            

12 45 5 9 3 24                                                                                                            

minimum absolute difference of server load is: 2

You might be interested in
How to make your nest learning thermostat stop doing something
k0ka [10]

Answer:

You could unplug it? LOL

and get a different thermostat.

Explanation:

Could you mark this answer as brainiest?

Thanks! :)

4 0
3 years ago
What determines gravitational pull?<br><br> volume<br><br> mass<br><br> the sun<br><br> acceleration
Arte-miy333 [17]
C. The sun is correct!
8 0
3 years ago
Read 2 more answers
Consider the following code:
Deffense [45]

Answer:

The output of C is 102.

100 + 1 + 1 = 102

8 0
3 years ago
Complete the sentence. <br><br> ____ Is the study and use of very small technology units
kondor19780726 [428]

Answer:

nanotechnology

Explanation:

I just took the test

3 0
3 years ago
Bradley is working on a program that uses different classes in specific relationships. Help him remember what these relationship
Kitty [74]

Answer:

First one is INHERITANCE. Second one is AGGREGATION.

3 0
3 years ago
Other questions:
  • David would like to send a letter to more than one hundred people. He would like the letter to have names and addresses inserted
    7·1 answer
  • SOMEONE PLEASE HELP ASAP!!
    14·2 answers
  • Under which market structure, does a firm have the most influence over product pricing? A. Oligopoly B. Perfect competition C. M
    5·1 answer
  • Write a method so that the main() code below can be replaced by the simpler code that calls method mphandminutestomiles(). origi
    14·2 answers
  • You can include up to _____ logical conditions in the and function.
    12·1 answer
  • apple and adobe are in disagreement about the use of __________ to create apps for the iphone and ipad?
    10·1 answer
  • Can someone please give me example of three types of loop in pascal (It has to has randomize in it too)
    15·1 answer
  • Your computer uses 4 bits to represent decimal numbers (0, 1, 2, 3 and so on) in binary. What is the SMALLEST number for which a
    8·1 answer
  • 5. Robotics deals with the design, construction, operation, and use of robots, as well as computer systems for their control, se
    14·1 answer
  • Write a function called st_dev. st_dev should have one
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!