Monday, April 14, 2008

5.three tapes on 13 programs

5.we want to store files of length (in MB) {12,5,32,7,5,18,26,4,3,11,10,6} on three TAPES. How should we store them on three tapes so that the mean retrieval is minimized?
SOLUTION: STORE FILES BY NONDECREASING LENGTH
First sort the files in increasing order of length. For this we use heap sort, merge sort or quick sort algorithms

Tape1 3

Tape2

Tape3

3 4 5 5 6 7 8 10 11 12 18 26 32
Now distribute the files:
First element 3

Second element 4
Tape1 3
Tape2 4
Tape3


Third element 5
Tape1 3
Tape2 4
Tape3 5



Fourth element 5
Tape1 3 5
Tape2 4
Tape3 5

Fifth element 6

Tape1 3 5
Tape2 4 6
Tape3 5




Sixth element 7
Tape1 3 5
Tape2 4 6
Tape3 5 7

Seventh element 8
Tape1 3 5 8
Tape2 4 6
Tape3 5 7

Eight element 10
Tape1 3 5 8
Tape2 4 6 10
Tape3 5 7

Ninth element 11
Tape1 3 5 8
Tape2 4 6 10
Tape3 5 7 11

Tenth element 12
Tape1 3 5 8 12
Tape2 4 6 10
Tape3 5 7 11



Eleventh element 18
Tape1 3 5 8 12
Tape2 4 6 10 18
Tape3 5 7 11

Twelth element 26
Tape1 3 5 8 12
Tape2 4 6 10 18
Tape3 5 7 11 26

Thirteenth element 32
Tape1 3 5 8 12 32
Tape2 4 6 10 18
Tape3 5 7 11 26



The total retrieval time of the tape1 (t0) =3+5+8+12+32=60
The total retrieval time of the tape2 (t1) =4+6+10+18=38
The total retrieval time of the tape3 (t2) =5+7+11+26=49

Minimized total retrieval time on above three tapes is 38 (t1)

No comments: