Suppose there are six files F1, F2, F3, F4, F5, F6 with corresponding sizes…
2017
Suppose there are six files F1, F2, F3, F4, F5, F6 with corresponding sizes 150 KB, 225 KB, 75 KB, 60 KB, 275 KB and 65 KB respectively. The files are to be stored on a sequential device in such a way that optimizes access time. In what order should the files be stored ?
- A.
F5, F2, F1, F3, F6, F4
- B.
F4, F6, F3, F1, F2, F5
- C.
F1, F2, F3, F4, F5, F6
- D.
F6, F5, F4, F3, F2, F1
Attempted by 310 students.
Show answer & explanation
Correct answer: B
Answer: F4, F6, F3, F1, F2, F5
Key idea: To minimize average access time on a sequential device, store files in increasing order of their sizes (place the smallest files first). This is analogous to scheduling jobs by shortest processing time to minimize average completion time.
Step 1: List the file sizes: F1 = 150 KB, F2 = 225 KB, F3 = 75 KB, F4 = 60 KB, F5 = 275 KB, F6 = 65 KB.
Step 2: Sort files by increasing size: F4 (60 KB), F6 (65 KB), F3 (75 KB), F1 (150 KB), F2 (225 KB), F5 (275 KB).
Step 3: Store files in that order to minimize cumulative waiting time: F4, F6, F3, F1, F2, F5.
Reason: Placing smaller files first reduces the average distance (or time) a read head must move past preceding data before reaching a requested file, thereby minimizing average access time.
A video solution is available for this question — log in and enroll to watch it.