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
forsale [732]
3 years ago
10

The SPF strategy can be proven to be optimal in the sense that it minimizes average response times. In this problem, you will de

monstrate this result empirically by examining all possible orderings for a given set of five processes. Suppose five different processes are waiting to be processed, and that they require 1, 2, 3, 4 and 5 time units, respectively. Write a program that produces all possible permutations of the five processes (5! = 120) and calculates the average waiting time for each permutation. Sort these into lowest to highest average waiting time order and display each average time side by side with the permutation of the processes. Comment on the results.

Computers and Technology
1 answer:
Anna35 [415]3 years ago
6 0

Answer:

Program;

#include <iostream>

#include <vector>

#include <algorithm>

using namespace std;

int main() {

vector<int> order = {1, 2, 3, 4, 5}; // initial job order

vector<pair<float, vector<int> > > data; // each pair is {average waiting time, jobs order}

int c = 0;

do {

// calculate average waiting time for the order

float avg_wait = 0;

for(int i = 0; i < order.size() - 1; ++i) {

avg_wait += order[i];

}

avg_wait /= 5;

data.push_back(make_pair(avg_wait, order));

} while(next_permutation(order.begin(), order.end()));

// sort according to average wait time

sort(data.begin(), data.end());

// display the result

cout << "avg_wait_time\tpermutation\n\n";

for(int i = 0; i < 120; ++i) {

cout << data[i].first << "\t\t";

for(int j = 0; j < 5; ++j) {

cout << data[i].second[j] << " ";

}

cout << endl;

}

Explanation:

See attachment for code screenshot

You might be interested in
During flashbacks you experience______.
Alina [70]
During flashbacks you see what happened in the past.
8 0
3 years ago
Read 2 more answers
The Internet raises the bargaining power of customers most effectively by: making information available to everyone. reducing ba
Elden [556K]

Answer:

Making information available to everyone.

Explanation:

The internet is a body of knowledge with diverse opinions, views and reviews. It has a wide range of information on virtually any product or services. When a customer is armed with this information, he or she would be able to increase his or her bargaining power efficiently.

4 0
4 years ago
L a s t. i achieve 15 of 15 question on brainly.
Veseljchak [2.6K]
The Control key on a computer keyboard is a key that is used by pressing it in combination with other keys, enabling other keys on the keyboard to perform secondary functions. It is generally labeled as Ctrl.
4 0
3 years ago
25% of 60 min<br> 20% of 60 min<br> 33%% of 60 min
Alexxx [7]
15
12
19.8 cool cool cool
7 0
2 years ago
The method __________ sets the font (helvetica, 20-point bold) in component
Stolb23 [73]
The method d) c.setFont(new Font("Helvetica", Font.BOLD, 20)) sets the font (Helvetica, 20­point bold) in component C. A set of instructions that can be called for execution using the method name is a method in Java that can take in data or parameters and return a value - both parameters and return values are optional.
7 0
3 years ago
Other questions:
  • Corey set up his presentation for delivery to his team. The information he had to convey was critical to their job performance.
    6·3 answers
  • Acts as a platform on which application software runs?
    6·1 answer
  • Lin is booting up his computer, and during the boot process, the computer powers down. After several unsuccessful attempts to bo
    12·1 answer
  • In an ethernet network, the signal that is sent to indicate a signal collision is called a ________ signal.
    7·1 answer
  • False
    8·1 answer
  • Write the SQL query that would search a table called Movies and return the titles of movies that were made in 1975.
    7·1 answer
  • Pls help due tonight<br>Will give brainiest
    13·2 answers
  • From which latin word the word computer is derived​
    7·1 answer
  • Name two living thing and nonliving thing that interact in an ecosystem
    10·1 answer
  • Olivia wants to change some settings in Outlook. What are the steps she will use to get to that function? open Outlook → File →
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!