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
makkiz [27]
4 years ago
12

Barr the Bear has started a business to sell fish to Poe and his fellow penguins. The penguin customers submit many fish orders,

but Barr can only process one order at a time. Suppose that Barr currently has orders from n penguin customers (label them as 1, 2, . . . , n). Customer i’s order takes ti time to complete. Barr is going to process each penguin’s order one by one, and the scheduling of orders can be described as a permutation of the customers. Let Ci denote the completion time of order i. For instance, if customer j’s order is the first to be completed, then we would have Cj = tj (assume Barr begins processing orders at time 0); if customer k’s order is the second to be completed after that, then Ck = Cj + tk = tj + tk, and so on. Each customer is of different importance to Barr’s business, and we denote this relative weight by wi (for customer i). Barr wishes to minimize the weighted sum of the completion times of n orders, Pn i=1 wi · Ci . Intuitively, the more important a customer is, the sooner Barr wishes to complete the customer’s order. Design an O(n log n) algorithm to solve this problem to help Barr. You are given a set of n orders with a processing time ti and a weight wi for each customer i (assume ti , wi are positive integers). You want to decide an ordering of the customer orders so as to minimize the weighted sum of the completion times. Prove correctness of your algorithm (i.e., optimality) and analyze its runtime.
Computers and Technology
1 answer:
luda_lava [24]4 years ago
5 0

Answer:

Algorithm below designed using Java

Explanation:

import java.util.SortedMap;

import java.util.TreeMap;

import java.util.Vector;

public class SchedulingProblem {

static Vector<Integer> processTime = new Vector<>();

static Vector<Integer> processWeight = new Vector<>();

static SortedMap<Integer, Double> timeWeightRatio = new TreeMap<Integer, Double>() {

};

 

static int number = 2;

public static void main(String[] args) {

processTime.add(1);

processWeight.add(10);

processTime.add(3);

processWeight.add(2);

for (int i = 0; i < number; i++) { // O(N)

timeWeightRatio.put(i, processWeight.get(i) / (processTime.get(i) * 1.0)); // O(log(n))

}

// ------------ O(nlog(n))

int sum = 0, tmpTime = 0;

while (timeWeightRatio.size() > 0) { // O(n)

tmpTime += processTime.get(timeWeightRatio.firstKey()); // O(n)

sum += processWeight.get(timeWeightRatio.firstKey()) * tmpTime; // O(n)

System.out.print(processWeight.get(timeWeightRatio.firstKey()) + " * " + tmpTime + ((timeWeightRatio.size() > 1) ? " + " : " = " + sum));

timeWeightRatio.remove(timeWeightRatio.firstKey()); // O(log(n))

}

 

// >>>> O(nlog(n))

}

}

You might be interested in
I'm doing a python assignment for my coding class, and the input part just isn't working, someone please help out and tell me wh
tigry1 [53]

,.....,.........mm malds quería saber

8 0
2 years ago
A _____ is a collection of rules for formatting, ordering, and error checking data sent across a network.
Jobisdone [24]

Answer:

Protocol

A network protocol is an established set of rules that determine how data is transmitted between different devices in the same network. Essentially, it allows connected devices to communicate with each other, regardless of any differences in their internal processes, structure or design. Network protocols are the reason you can easily communicate with people all over the world, and thus play a critical role in modern digital communications.

3 0
3 years ago
A ____ is a device that not only provides surge protection, but also furnishes your computer with battery backup power during a
Anon25 [30]
Uninterruptible Power Supply (UPS)
6 0
4 years ago
Develop an sec (single error correction) code for a 16-bit data word. generate the code for the data word 0101000000111001. show
Kipish [7]

Answer:

code = 010100000001101000101

Explanation:

Steps:

The inequality yields 2^{k} - 1 > = M+K, where M = 16. Therefore,

The second step will be to arrange the data bits and check the bits. This will be as follows:

Bit position              number              Check bits            Data Bits

21                                   10101

20                                  10100

The bits are checked up to bit position 1

Thus, the code is 010100000001101000101

3 0
4 years ago
Read 2 more answers
Sam is developing a software program in Python and has a question about how to implement a particular feature.
Over [174]

Answer:

The correct answer is:

"joining a Python developer forum and posting a question to the forum to solicit feedback"

Explanation:

Learning a new skill involves a lot of research and study especially learning a new programming language.

The syntax and commands have to be understood first.

Now if Sam has to implement a particular feature, the easiest and less time-consuming way is that he post his query on a Python language forum as there might be better and expert programmer that might help

Hence,

The correct answer is:

"joining a Python developer forum and posting a question to the forum to solicit feedback"

5 0
3 years ago
Read 2 more answers
Other questions:
  • MinMax is a function that takes five arguments and returns no value. The first three arguments are of type int. The last two arg
    14·1 answer
  • Machine language is made up of which following codes
    11·1 answer
  • In an inheritance situation, the new class that you create from an existing class is known as the:
    5·1 answer
  • Design a 4-to-16 line Decoder by using the two 3*8 decoder-line decoders. The 3-to-8 line decoders have an enable input ( '1' =e
    13·1 answer
  • How does form get its power natural gas
    14·1 answer
  • Compare and contrast Charles bebbage and Blaise Pascal inventions<br>​
    14·1 answer
  • FREE BRAINLIEST!!!
    14·2 answers
  • A set of object that share a common structure and common behavior in database is called ​
    13·1 answer
  • 3) Given that HSI (360, 0.000, 1.000), What is the equivalent RGB<br> color?
    12·1 answer
  • Susan is a network administrator and is setting up her company's network. In the process to determine an open port on a firewall
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!