All Exams Test series for 1 year @ ₹349 only
Question

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?

The correct answer is

F4, F6, F3, F1, F2, F5

Optimizing File Storage Order on Sequential Devices

To optimize access time when storing files on a sequential device, the files should be arranged in increasing order of their sizes. This is because accessing a file on a sequential device involves reading through the preceding files. By placing smaller files first, the total time spent reading through data to reach any particular file is minimized, thereby reducing the average access time. This principle is similar to the Shortest Job First (SJF) scheduling algorithm used in operating systems.

Let's list the given files and their sizes:

  • F1: 150 KB
  • F2: 225 KB
  • F3: 75 KB
  • F4: 60 KB
  • F5: 275 KB
  • F6: 65 KB

Now, we need to sort these files based on their sizes in ascending order.

File Size (KB)
F4 60
F6 65
F3 75
F1 150
F2 225
F5 275

Arranging the files in increasing order of size gives us the following sequence:

  • F4 (60 KB)
  • F6 (65 KB)
  • F3 (75 KB)
  • F1 (150 KB)
  • F2 (225 KB)
  • F5 (275 KB)

Therefore, the optimal order for storing the files on a sequential device to optimize access time is F4, F6, F3, F1, F2, F5.

Let's compare this optimal order with the given options:

  • Option 1: F5, F2, F1, F3, F6, F4 (Sorted by decreasing size)
  • Option 2: F4, F6, F3, F1, F2, F5 (Sorted by increasing size)
  • Option 3: F1, F2, F3, F4, F5, F6 (Original order)
  • Option 4: F6, F5, F4, F3, F2, F1 (Not sorted by size in any consistent order)

The optimal order F4, F6, F3, F1, F2, F5 matches Option 2.

Revision Table: File Storage Order Optimization

File Size (KB) Optimal Order Position
F4 60 1st
F6 65 2nd
F3 75 3rd
F1 150 4th
F2 225 5th
F5 275 6th

Additional Information on Sequential Access Devices and Access Time

A sequential access device, like a magnetic tape drive, requires data to be accessed in a linear sequence. To read data located at a specific point, the device must first read or skip all the data that comes before it. Unlike random access devices (like hard disk drives or SSDs) where any data block can be accessed almost directly, sequential access involves mechanical movement (like winding tape) that takes time.

When multiple files are stored on such a device, the time taken to access a specific file depends on its position and the sizes of the files preceding it. If a large file is stored early in the sequence, accessing any file after it will take a considerable amount of time because the entire large file must be read or skipped. By sorting files by increasing size, the "waiting time" (the time spent skipping data before the desired file) is minimized for files that appear later in the sequence. This strategy aims to reduce the average access time across all files, assuming files are accessed with some probability. Storing the smallest files first ensures that these frequently potentially accessed smaller files are reached quickly, and the cumulative size of files to be skipped to reach any point is minimized compared to other orderings.

Was this answer helpful?

Important Questions from Greedy Algorithms - Teaching

  1. Match List-I with List-II:

    List-I

    List-II

    (a) Greedy best-first

    (i) Minimal cost (p)+h(p)

    (b) Lowest cost-first

    (ii) Minimal h(p)

    (c) A* algorithm

    (iii) Minimal cost (p)

    Choose the correct option from those given below:

  2. A text is made up of the characters A, B, C, D, E each occurring with the probability 0.08, 0.40, 0.25, 0.15 and 0.12 respectively. The optimal coding technique will have the average length of:

  3. Which among the following statement(s) is(are) FALSE?

    A. Greedy best‐first search is not optimal but is often efficient.

    B. A* is complete and optimal provided h(n) is admissible or consistent.

    C. Recursive best‐first search is efficient in terms of time complexity but poor in terms of space complexity.

    D. h(n) = 0 is an admissible heuristic for the 8‐puzzle.

  4. A text is made up of the characters a, b, c, d, e each occurring with the probability 0.11, 0.40, 0.16, 0.09 and 0.24 respectively. The optimal Huffman coding technique will have the average length of :

  5. If b is the branching factor and m is the maximum depth of the search tree, what is the space complexity of greedy search ?  

Need Expert Advice?

Start Your Preparation with Prepp Mobile App

Download the app from Google Play & App Store
Download the app from Google Play & App Store
Prepp Mobile App