Given a set of jobs {J1, ... , Jn}, each job Ji = < ti, wi > has a required processing time ti and a weight wi. Design an efficient algorithm (pseudo code) to minimize the weighted sum of overall completion times ∑ni=1wiCi, where Ci is the completion time of job i. What is the time complexity of your algorithm? Note: You first need to briefly explain your ideas to solve the problem, e.g. what data structures are used, how the intermediate results are saved, which sorting strategy is used, and why the final results are correct;

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 18SA
icon
Related questions
Question

Given a set of jobs {J1, ... , Jn}, each job Ji = < ti, wi > has a required processing time ti and a
weight wi. Design an efficient algorithm (pseudo code) to minimize the weighted sum of overall
completion times ∑ni=1wiCi, where Ci  is the completion time of job i. What is the time complexity
of your algorithm?

Note: You first need to briefly explain your ideas to solve the problem, e.g. what data structures are
used, how the intermediate results are saved, which sorting strategy is used, and why the final
results are correct; 

Expert Solution
Step 1

A common approach to solve this problem is to use a greedy algorithm. The idea is to sort the jobs in decreasing order of the ratio wi/ti, and then schedule them one by one. This way, we ensure that the job with the highest weight/time ratio is completed as soon as possible, which in turn minimizes the weighted sum of overall completion times.

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Introduction to Greedy algorithm
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning