Introduction to Algorithms
3rd Edition
ISBN: 9780262033848
Author: Thomas H. Cormen, Ronald L. Rivest, Charles E. Leiserson, Clifford Stein
Publisher: MIT Press
expand_more
expand_more
format_list_bulleted
Question
Chapter 16, Problem 2P
(a)
Program Plan Intro
To design an
(b)
Program Plan Intro
Tasks are running in the preemptive fashion and cannot occur at the same time.Todesign algorithm to schedule tasks to minimizesthe average completion time and to show its complexity.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Job scheduling: Consider the problem of scheduling n jobs of known durations
t1, t2, . . . , tn for execution by a single processor. The jobs can be executed in any order, one job at a time. You want to find a schedule that minimizes the total time
spent by all the jobs in the system. (The time spent by one job in the system is the sum of the time spent by this job in waiting plus the time spent on its execution.) Design a greedy algorithm for this problem. Does the greedy algorithm always yield an optimal solution? (Hint: You may get a clue from Prim’s Algorithm)
As a teaching administrator of the department, your responsibility is to schedule the
classes for a particular classroom. Suppose there are n classes, each class i is
represented by its start time and finishing time [Si, fi], and we say that two classes i
and j are non-conflicting if they do not overlap in time (i.e., sizfj or szfi). You want to
schedule as many classes for the classroom as possible, but the scheduled classes
should be non-conflicting. Develop an algorithm so that you can select the maximum
number of classes for the classroom. (We are expecting either pseudocode or
language description of your algorithm)
In a private university, students can enrol for at least 1 to a maximum of 5
subjects in a semester. Subjects that are to be offered in that particular
semester will be assigned to a class. One class should have at least 5
students and up to a maximum of 40 students. Multiple classes for a subject
can be created if the students number enrolled for the subject is large. A
subject might not be offered on that semester depending on the needs. A
lecturer can be assigned to zero and up to a maximum of 4 classes on that
particular semester. Draw the class diagram to represent the above scenario.
Each entity should have at least 1 attribute as its identity. Provide the relevant
associations between these entities and include the multiplicities.
Chapter 16 Solutions
Introduction to Algorithms
Ch. 16.1 - Prob. 1ECh. 16.1 - Prob. 2ECh. 16.1 - Prob. 3ECh. 16.1 - Prob. 4ECh. 16.1 - Prob. 5ECh. 16.2 - Prob. 1ECh. 16.2 - Prob. 2ECh. 16.2 - Prob. 3ECh. 16.2 - Prob. 4ECh. 16.2 - Prob. 5E
Ch. 16.2 - Prob. 6ECh. 16.2 - Prob. 7ECh. 16.3 - Prob. 1ECh. 16.3 - Prob. 2ECh. 16.3 - Prob. 3ECh. 16.3 - Prob. 4ECh. 16.3 - Prob. 5ECh. 16.3 - Prob. 6ECh. 16.3 - Prob. 7ECh. 16.3 - Prob. 8ECh. 16.3 - Prob. 9ECh. 16.4 - Prob. 1ECh. 16.4 - Prob. 2ECh. 16.4 - Prob. 3ECh. 16.4 - Prob. 4ECh. 16.4 - Prob. 5ECh. 16.5 - Prob. 1ECh. 16.5 - Prob. 2ECh. 16 - Prob. 1PCh. 16 - Prob. 2PCh. 16 - Prob. 3PCh. 16 - Prob. 4PCh. 16 - Prob. 5P
Knowledge Booster
Similar questions
- After college, a group of students of a certain height planned to go to the movies. The cinema they go to is quite unique because the number of cinema rows is always 2 and the number of seats is as many as the number of students. Because this is a unique cinema, the way they sit is also unique. They will try to minimize their height difference with the one next to it so that the biggest height difference of each pair of students next to each other is as minimal as possible. Example: There are 6 students with height of 1, 6, 9, 7, 2, and 3. There are various sequences that can produce the biggest difference in height. Ordering 1:1 3 62 7 9Difference 1 and 3 is 2.Difference 3 and 6 is 3.Difference 2 and 7 is 5.Difference 7 and 9 is 2.So the biggest difference in height is 5. Ordering 2:1 3 26 7 9The biggest difference in height is 2.This difference is also an optimal answer. Format Input : There are T test cases. Each testcase contains integers N which indicates the number of students…arrow_forwardSuppose you have a set of proposed activities along with start time a; and finish time f; where 0 < ai, fiarrow_forwardBus timetables specify to the second the exact arrival and departure time of each bus on each stop. You need to pay for the full fare of every bus you ride and different bus lines charge different fees , but they are flat fees (independent of distance travelled on the line) A travel plan is a sequence of stop-time pairs where stop is a location of a bus stop and time is when we arrive at that stop. The plan is feasible if for any two consecutive pairs (a, t) and (b, t′) in the plan there exists a bus that departs after t and arrives at b at exactly t′. That is, a travel plan does not allow us to walk between stops. Assuming that no two buses arrive at the same time at the same stop, a feasible plan uniquely identifies the bus lines that we need to take to realize the plan. The cost of the plan is the sum of the fares we need to pay. Your task is to design an efficient algorithm that given a departure time t, an arrival time t′, an origin stop a and a destination stop b, finds the…arrow_forwardDeadlock avoidance: Select all of the following statements that are true. Deadlock avoidance aims to ensure that a system of processes will never enter an unsafe state. Claim edges in resource allocation graphs indicate resource requests that a process may send out in the future. The banker's algorithm can only be applied when there are single units of each resource type only. In order for the banker's algorithm to be applicable, when a process starts up, it must state in advance the maximum number of resources it may request. After the execution of the banker's algorithm, if Finish[i] == false for all processes i, then the system is in a safe state. Unsafe system states can lead to deadlocks.arrow_forwardYou have one supercomputer and ʼn normal computers on which you need to run ʼn jobs. Each job i first spends s; time on the supercomputer and then n; time on the normal computer. A job can only start running on any of the normal computers after it has finished on the supercomputer. However, as soon as any job finishes on the supercomputer, it can immediately start on one of the free normal computers. The goal is to finish running all the jobs as soon as i=n possible. Note that since there is only one supercomputer, you'll always have to wait - Si i=1 time so that the jobs finish running on the supercomputer. However, you can optimize when you run the jobs on the normal computers to try to finish running all the jobs as soon as possible. Show that by executing jobs after sorting them in decreasing order by nį, you have an optimal schedule.arrow_forwardYou are organizing a conference that has received n submitted papers. Your goal is to get people to review as many of them as possible. To do this, you have enlisted the help of k reviewers. Each reviewer i has a cost sij for writing a review for paper j. The strategy of each reviewer i is to select a subset of papers to write a review for. They can select any subset S; C {1,2, ..., n}, as long as the total cost to write all reviews is less than T (the time before the deadline): 2 Sij 1. (b) Show that for B = 2 this fraction is close to 1/3. [Hint: You can consider an instance with 3n + 1 papers and only n will be reviewed.]arrow_forwardProject Optimization and regression: Exact and approximate methods to solve 0-1 Knapsack problem Description The 0/1 Knapsack Problem and Logistics Transportation companies such as TNT and Royal Mail face daily problems in logistics. Consider the following simple logistics problem, which you will solve: An airline cargo company has 1 aeroplane which it flies from the UK to the US on a daily basis to transport some cargo. In advance of a flight, it receives bids for deliveries from (many) customers. Customers state the weight of the cargo item they would like delivered, and the amount they are prepared to pay. The airline is constrained by the total amount of weight the plane is allowed to carry. The company must choose a subset of the packages (bids) to carry in order to make the maximum possible profit, given the weight limit that they must respect. In mathematical form the problem is: Given a set of N items each with weight wi and value vi, for i=1 to N, choose a subset of items…arrow_forwardSuppose that a manufacturing company builds n different types of robots, sayrobots 1, 2, . . . , n. These robots are made from a common set of m types of materials, saymaterials 1, 2, . . . , m. The company has only a limited supply of materials for each year,the amount of materials 1, 2, . . . , m are limited by the numbers b1, b2, . . . , bm, respectively.Building robot i requires an aij amount from material j. For example, building robot 1requires a11 from material 1, a12 from material 2, etc. Suppose the profit made by sellingrobot i is pi. Write an integer linear program for maximizing the annual profit for thecompanyarrow_forward、Simulation of bank calling system[Problem Description]Using linear list to simulate the bank's queuing business model[Basic Requirements]1) Suppose that the working hours of the bank are from 9 a.m. to 5 p.m2) The time when customers arrive at the bank is generated randomly, and the customers are queued in the order of arrival. The time required for each customer to handle business can also be generated randomly, no more than 30 minutes. If the randomly generated time length is 0, it indicates that the customer leaves early and does not handle business.3) When the program is running, input the number of bank windows, and then output the basic information of each customer's business in the bank according to the randomly generated customer data (arrival time, time required for business), including: customer arrival time, customer waiting time, what time the customer handled business in which window, and how long the business lasted. From this, we can observe the average…arrow_forwardScheduling select which is true options: a The average waiting time for a given set of processes is minimal when Shortest Job First (SJF) scheduling algorithm is used. b Round Robin (RR) scheduling can lead to starvation. c Priority inversion means that high-priority processes can be delayed or blocked by lower-priority processes. d The service time is also known as the CPU burst. e The method of exponential averaging can be used to increase the priority of jobs according to their waiting time.arrow_forwardGiven a set ? = {?1, ?2, … , ??} of tasks, where ?? requires ?? units of processing time to finish once it has started. There is only one computer to run these tasks one at a time. The time before a task ?? starts is called its waiting time ????. The goal is come up with a schedule to minimize the overall waiting time ∑n ?? ?=1 .(1) Give an example to show the greedy choice property and the optimal substructure in thisproblem,(2) Design a greedy algorithm to solve this problem,(3) Analyze the complexity of your algorithm.arrow_forward1. Design an efficient algorithm to solve the following scheduling problem. Provide a pseudo- code and a worst case complexity analysis for your algorithm. You are given a set of n jobs with a processing time t; and a weight w; for each job. You want to order the jobs so as to minimize the weighted some of the completion times, Žw,C, . i=1 Example: Suppose there are two jobs, the first takes time ti = 1 and has weight wi = 10, while the second takes time t2 = 3 and has weight w2 = 2. Then doing job 1 first would yield a weighted completion time of 10x1 + 2x4 = 18, while doing job 2 first yields the larger weighted completion time of 10x4 + 2x3 = 46.arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_ios
Recommended textbooks for you
- Operations Research : Applications and AlgorithmsComputer ScienceISBN:9780534380588Author:Wayne L. WinstonPublisher:Brooks Cole
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole