Professional Documents
Culture Documents
Algoritma Analizi 10-TRSlides
Algoritma Analizi 10-TRSlides
Zahra ELMI
Zahra.elmi@izu.edu.tr
Algoritma tasarım teknikleri
Tanım
J = { j1 ,j2 ,··· ,jn } , n iş kümesi verildi. Her
ji işinin bitmesi için ti zaman gerekir.
İşler tek tek yapılır.
Example
t1 = 5, t2 = 10 and t3 = 3 olduğunu varsayalım. Aşağıdaki
düzenlemeler mümkündür:
⟨t1 ,t2 ,t3 ⟩ =⇒ T = 5 + (5 + 10) + (5 + 10 + 3) = 38
⟨t1 ,t3 ,t2 ⟩ =⇒ T = 5 + (5 + 3) + (5 + 3 + 10) = 31
⟨t2 ,t1 ,t3 ⟩ =⇒ T = 10 + (10 + 5) + (10 + 5 + 3) = 43
⟨t2 ,t3 ,t1 ⟩ =⇒ T = 10 + (10 + 3) + (10 + 3 + 5) = 41
√
⟨t3 ,t1 ,t2 ⟩ =⇒ T = 3 + (3 + 5) + (3 + 5 + 10) = 29
⟨t3 ,t2 ,t1 ⟩ =⇒ T = 3 + (3 + 10) + (3 + 5 + 10) = 35
İş Planlama Problemi
Aşağıdaki algoritma, İş Planlama problemini çözmektedir:
Greedy-Job-Scheduling-Algorithm(I = ⟨t1, t2,··· ,tn ⟩){
Sort I in nondecreasing order, sayI = ⟨ti1 ,ti2 ,··· ,tin ⟩;
// Perform the jobs with respect to the sorted arangement;
While (I != 0 ){
x ← First element of I;
I ← I − { x};
Performs the job x ;
}
}
İş Planlama Problemi
Aşağıdaki algoritma, İş Planlama problemini çözmektedir:
Greedy-Job-Scheduling-Algorithm(I = ⟨t1, t2,··· ,tn ⟩){
Sort I in nondecreasing order, sayI = ⟨ti1 ,ti2 ,··· ,tin ⟩;
// Perform the jobs with respect to the sorted arangement;
While (I != 0 ){
x ← First element of I;
I ← I − { x};
Performs the job x ;
}
}
Theorem
Yukarıdaki algoritma, herhangi bir sistemdeki toplam bekleme süresi
minimum olacak şekilde iş çizelgeleme problemini çözmektedir.
İş Planlama Problemi
Proof.
n
T (I) = ∑ ( n − k + 1) tik , if Iopt is not sorted, then ∃a, b : a < b and tia > tib
k =1
1 2 a b n
I opt i1 i2 ia ib in
ti1 ti2 tia tib tin
1 2 a b n
I opt i1 i2 ia ib in
ti1 ti2 tia tib tin
n
T ( Iopt ) = ∑ ( n − k + 1) ti k
k =1
n
T ( Io′ pt ) = ∑ ( n − k + 1) tik + ( n − a + 1) tib + ( n − b + 1) tia
k =1
k=
! a, b
Job Scheduling Problem
Proof.
n
T (I) = ∑ ( n − k + 1) ti k , if Iopt is not sorted, then ∃a, b : a < b and tia > tib
k =1
1 2 a b n
I opt i1 i2 ia ib in
ti1 ti2 tia tib tin
n
T ( Iopt ) = ∑ ( n − k + 1) ti k
k =1
n
T ( Io′ pt ) = ∑ ( n − k + 1) tik + ( n − a + 1) tib + ( n − b + 1) tia
k =1
k !=a, b