Question

Consider a linear list based directory implementation in a file system. Each directory is a list of nodes, where each node contains the file name along with the file metadata, such as the list of pointers to the data blocks. Consider a given directory foo.

Which of the following operations will necessarily require a full scan of foo for successful completion?

Choose every correct option
Official answer and solution
Official answer
A and C
From
Official GATE 2021 answer key

Solution

Identify which directory operations require verifying that no duplicate file name exists in an unsorted linear list.

In a file system directory, all file names within a given directory must be strictly unique. In an unsorted linear list implementation, searching for a name requires traversing the list node by node.

  • Creation of a new file (Option A): To maintain unique naming, the file system must first verify that no existing file already has the new file's name. Because the target name does not exist, the search cannot find a match and must scan the entire list to the very end before adding the new node. (Full scan required)
  • Deletion of an existing file (Option B): The scan terminates as soon as the target file node is located and unlinked. If the file is near the beginning, only a partial scan is performed. (Full scan not necessarily required)
  • Renaming of an existing file (Option C): Renaming requires verifying that the target new name does not already exist in the directory. Checking for non-existence of the new name requires scanning all nodes to the end. (Full scan required)
  • Opening of an existing file (Option D): The search terminates as soon as the existing file is found. (Full scan not necessarily required)

Therefore, operations A and C necessarily require a full scan of the directory.

Final answer

A, C

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2021 Computer Science and Information Technology (CS, Set-1)
Question
25 of 65, printed as CS Q.15
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.