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
Which website citation is correctly formatted according to MLA standards?
inysia [295]

Answer:

<em><u>The</u></em><em><u> </u></em><em><u>answer</u></em><em><u> </u></em><em><u>is</u></em><em><u> </u></em><em><u>C</u></em><em><u> </u></em><em><u>no</u></em>

Explanation:

<em><u>Hope</u></em><em><u> </u></em><em><u>it</u></em><em><u> </u></em><em><u>will</u></em><em><u> </u></em><em><u>help</u></em><em><u> </u></em><em><u>you</u></em><em><u> </u></em><em><u>dear</u></em><em><u> </u></em><em><u /></em>

7 0
2 years ago
Read 2 more answers
Plz answer all the questions :)
AURORKA [14]

Answer:

is there multiple choice or do i have to answer from my own words??

7 0
3 years ago
Before renting or buying a multifamily dwelling you should know the __ of the building
mel-nik [20]
You should know the units :))))))))))))
8 0
3 years ago
Read 2 more answers
1. Which raster image file type supports millions of colors and transparency?
Alona [7]

Answer:

PNG-24

Explanation:

6 0
3 years ago
A function name differs from a variable name because a function name is immediately followed by a set of ____.
Mashcka [7]
A set of <span>parentheses. ()
Hope so !!!</span>
4 0
4 years ago
Other questions:
  • To name a computed field, follow the computation with the word ____ and then the name you wish to assign to the field
    8·1 answer
  • What is the meaning for science?
    14·1 answer
  • Two students are discussing the flow of electricity. Student A says that voltage is a measure of the amount of electron flow in
    8·1 answer
  • What is the use of jacquard loom
    13·2 answers
  • Jane is creating a slide that will have a large heading and number of bullet points below it. What slide format should she use?
    12·1 answer
  • JAVA
    12·1 answer
  • Examples of email use that could be considered unethical include _____.
    14·2 answers
  • Pleasee helpppppppppppppppppppppp me!
    7·1 answer
  • Which key combination should you use
    9·2 answers
  • Arrange the Jumbled letters 1.eilf ngrihsa ________________ 2.cersityu ourreecs ________________ 3. ngrihsa ________________ 4.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!