• Tidak ada hasil yang ditemukan

CSL 356: Analysis and Design of Algorithms

N/A
N/A
Protected

Academic year: 2024

Membagikan "CSL 356: Analysis and Design of Algorithms"

Copied!
10
0
0

Teks penuh

(1)

Ragesh Jaiswal CSE, IIT Delhi

CSL 356: Analysis and Design of

Algorithms

(2)

Greedy Algorithms: Example

Fractional Knapsack: You are a thief and you have a sack of size W. There are n divisible items. Each item i has a volume W(i) and total value V(i). How will you maximize your

profit?

W = 50

20 50 30

10 50

25 60 30

GreedySteal

While Sack is not full

- Choose an item i from R that has the largest cost per unit volume - Put as much as you can of this item in the sack and delete i from R

(3)

Greedy Algorithms: Example

Consider items in decreasing order of the cost per unit volume value.

Let (G1,…,Gn) be the volume of items in the sack chosen by GreedySteal.

Let (O1,…,On) be some optimal volume of items that maximizes the profit.

Claim: For all i, G1*d1+…+Gi*di ≥ O1*d1+…+Oi*di

(4)

Digression

Running time of topological sort

(5)

Greedy Algorithms: Example

Job Scheduling: You are given n jobs and you are supposed to schedule these jobs on a machine. Each job i consists of a

duration T(i) and a deadline D(i). The lateness of a job wrt.

a schedule is defined as max(0, F(i) – D(i)), where F(i) is the finishing time of job i as per the schedule. The goal is to minimize the maximum lateness.

Greedy Strategies:

Smallest jobs first.

(6)

Greedy Algorithms: Example

Job Scheduling: You are given n jobs and you are supposed to schedule these jobs on a machine. Each job i consists of a

duration T(i) and a deadline D(i). The lateness of a job wrt.

a schedule is defined as max(0, F(i) – D(i)), where F(i) is the finishing time of job i as per the schedule. The goal is to minimize the maximum lateness.

Greedy Strategies:

Smallest jobs first.

Earliest deadline first.

GreedyJobSchedule

- Sort the Jobs in increasing order of deadlines and schedule the jobs on the machine in this order.

(7)

Greedy Algorithms: Example

Claim: There is an optimal schedule with no idle time (time when the machine is idle).

Definition: A schedule is said to have inversion if there are a pair of jobs (i, j) such that

1. D(i) < D(j), and

2. Job j is performed before job i as per the schedule.

Claim: There is an optimal schedule with no idle time and no inversion.

Proof: Consider an optimal schedule O. First if there is any idle time we obtain another optimal schedule O1 without idle time. Suppose O1 has inversions. Consider one such inversion (i, j).

(8)

Greedy Algorithms: Example

Claim: There is an optimal schedule with no idle time and no inversion.

Proof: Consider an optimal schedule O. First if there is any idle time we obtain another optimal schedule O1 without idle time. Suppose O1 has inversions. Consider one such inversion (i, j).

j i

D(i) D(j)

There exists a pair of adjacently scheduled jobs (m,n) such that the schedule has an inversion wrt. (m,n).

(9)

Greedy Algorithms: Example

Claim: Exchanging m and n does not increase the maximum lateness.

m n

D(n) D(m)

n m

D(n) D(m)

(10)

End

Problems to think about:

1. Consider the job scheduling problem. Can you think of an example where there is a unique optimal schedule.

Referensi

Dokumen terkait

We want to compare the expected performance values of the two algorithms: H0:1¼2 vs.16¼2 ð2Þ and in a paired setting, we test if their paired difference has zero mean: H0:d12¼0

To assist in these engineering efforts, analysis algorithms have been developed to enable calculation of the equilibrium base pairing properties of a dilute solution of interacting

Start The 2018 EPI dataset Imputation algorithms the special clustering algorithms GoF p ≥0.9 K-means The result of clustering Comparison by using Silhouette index The optimal

To check the flaws with digital signatures in symmetric key algorithms and to analyze and understand the remedial security practices through cryptography 1.2 Literature Review RSA is

Support is the percentage combination of these items in the database; confidence is the strength of the relationship between items in the association rules; lift ratio is to test the

Complete diagram of the designed fish dryer closed MODEL FORMULATION The control volume of the elemental tray of the dryer was used for the development of the mathematical model for

• complexity of algorithms and problems • Strassen's matrix multiplication Models of computation: the ultimate RISC Algorithm and computability are originally intuitive concepts..

CONCLUSION Based on the test results to get good performance from the Round Robin and Priority Scheduling scheduling algorithms with YAFS tools, it can be concluded that the Round