solution - Operating System : File Management (Test 2)

Question : Which of the following problems is NOT directly associated with single-level directories?

Solution :
638520260321080553 Correct Answer : Path traversal complexity

Description -

The correct choice is Path traversal complexity.

Brief Explanation

A single-level directory is the simplest directory structure, where all files are stored in a single master directory and share a completely flat layout.

Because of this flat layout, it suffers from several severe limitations:

  • Naming problem: Two files cannot have the same name because they exist in the exact same directory space.
  • Grouping problem: Users cannot organize or group related files together (e.g., placing all photos in one folder and homework in another).
  • Security limitation: In a multi-user environment, it is difficult to isolate or protect one user's files from another since everything sits in one shared room.

Question : Which scenario best justifies the use of a single-level directory?

Solution :
389820260321080453 Correct Answer : Small system with limited number of files

Description -

The correct choice is Small system with limited number of files.

Brief Explanation

A single-level directory is a completely flat file system where all files are stored in one single directory. Because there are no subfolders, it becomes chaotic and unmanageable as the number of files or users grows.

However, it is perfectly justified for small systems with a very limited number of files (such as early personal computers like CP/M, simple embedded systems, microcontrollers, or basic bootable media) for the following reasons:

  • Minimal Overhead: It requires very little memory and processing power to implement because the operating system does not need complex lookup logic or path traversal algorithms.
  • Simplicity: When a system only handles a handful of fixed files, advanced features like grouping, hierarchical organization, and multi-user security constraints are completely unnecessary.

Question : Why does file searching become inefficient in a single-level directory when the number of files increases?

Solution :
313320260321080357 Correct Answer : All files are stored in one directory without categorization

Description -

The correct choice is All files are stored in one directory without categorization.

Brief Explanation

In a single-level directory, there is only one flat table or list that holds every single file on the entire system. As the number of files increases, this architecture becomes highly inefficient due to the following reasons:

  • Linear Searching: Because there are no sub-directories or categories, the operating system is forced to perform a linear (sequential) search from the top of the list to the bottom to find a specific file or to verify a name collision when creating a new file.
  • Lack of Isolation: In a hierarchical system, you can limit your search to a single small folder (e.g., searching only inside /Photos). In a single-level directory, the system must scan through every document, system file, and configuration file simultaneously, causing the search time to scale poorly as the file count grows.

Question : Which of the following is the major limitation of a single-level directory in a multi-user system?

Solution :
261920260321080306 Correct Answer : Naming conflicts among users

Description -

The correct choice is Naming conflicts among users.

Brief Explanation

In a single-level directory, there is only one shared, flat directory space for the entire system. In a multi-user environment, this architecture introduces a massive bottleneck:

  • Lack of Isolation: Because all files from all users live in the exact same directory, no two files can share the same name.
  • The Conflict: If User A creates a file named txt, User B is completely blocked from creating a file named notes.txt. Users must continuously coordinate with one another to invent completely unique filenames, making collaboration and privacy virtually impossible.

Question : In a single-level directory structure, which of the following is a mandatory constraint?

Solution :
58520260321080215 Correct Answer : Each file must have a unique name

Description -

The correct choice is Each file must have a unique name.

Brief Explanation

A single-level directory is a completely flat file system where every single file is stored in one master list. Because there are no sub-directories or separate folders to provide context or isolation, the system enforces a strict uniqueness constraint:

  • Name Collisions: The operating system tracks files using their names within that single directory table. If two files had the exact same name, the system would have no way to differentiate between them when opening, writing, or deleting.
  • Lack of Isolation: Because everyone and everything shares the exact same space, every single filename must be completely distinct across the entire system.

Question : Why is searching faster in a two-level directory compared to a single-level directory?

Solution :
815620260321080100 Correct Answer : Only one user’s directory needs to be searched

Description -

The correct choice is Only one user’s directory needs to be searched.

Brief Explanation

A two-level directory structure divides the file system into a Master File Directory (MFD) and separate User File Directories (UFDs) for each individual user.

  • Targeted Search Space: When a user logs in and searches for or creates a file, the operating system isolates the search exclusively to that specific user's UFD.
  • Drastic Reduction in Files Scanned: Instead of performing a slow, linear scan through a single massive list containing every single file belonging to every user on the system (as happens in a single-level directory), the system only searches a fraction of the total files, resulting in significantly faster lookup speeds.

Question : Which of the following is a major disadvantage of a two-level directory?

Solution :
402220260321080021 Correct Answer : Lack of file sharing between users

Description -

The correct choice is Lack of file sharing between users.

Brief Explanation

While a two-level directory structure successfully solves the naming conflict problem by giving each user their own isolated User File Directory (UFD), it introduces a major drawback regarding collaboration:

  • Strict Isolation: The system effectively places walls between users. Because the structure is rigidly split into just two levels (Master File Directory \(\rightarrow \) User File Directories), there is no built-in mechanism to easily share files or collaborate.
  • Access Restraints: A user cannot easily access or run a file residing in another user's UFD. To share a file, the operating system either has to copy the file completely into the other user's directory (wasting storage space) or require special system-level permissions, making seamless file sharing highly difficult compared to tree-structured or graph directory systems.

Question : In a two-level directory system, the pathname of a file is typically:

Question : Which of the following is NOT a feature of a two-level directory system?

Solution :
772420260321075828 Correct Answer : Ability to create subdirectories inside UFD

Description -

Ability to create subdirectories inside UFD is NOT a feature of a two-level directory system.

Why this is the correct answer:

  • Strict Two-Level Limit: A two-level directory system is strictly capped at exactly two levels: the Master File Directory (MFD) at the top, and individual User File Directories (UFDs) at the bottom.
  • Flat User Space: Inside a user's UFD, the structure is completely flat—just like a single-level directory. A user cannot create nested folders, subfolders, or subdirectories inside their UFD to further organize their files. The ability to create arbitrary subdirectories is the defining feature of a Tree-Structured (Hierarchical) Directory System, not a two-level system.

Why the other options are incorrect (as they ARE features):

  • Same file names allowed for different users: This is a core feature. Because User A and User B have separate UFDs, User A can have a file named docx and User B can also have a file named project.docx without any conflict.
  • Efficient searching within user directory: This is a primary feature. The OS narrows its search down immediately to the specific user's UFD, ignoring thousands of other files belonging to other users.
  • User-level file isolation: This is a fundamental feature. It naturally separates files by user account, preventing users from accidentally seeing or overwriting each other's work.

Question : In a two-level directory structure, the Master File Directory (MFD) primarily stores:

Solution :
84220260321075741 Correct Answer : Entries of user directories

Description -

In a two-level directory structure, the Master File Directory (MFD) does not store the actual files or their contents. Instead, it serves as the top-level directory that organizes user directories.

 The correct answer is: Entries of user directories

Quick breakdown of the options:

  • All files of all users  → Files are stored in user directories, not directly in the MFD.
  • File contents→ Contents are stored in the file system, not in the directory structure.
  • Entries of user directories → MFD contains references (entries) to each user’s directory.
  • Only system files  → That’s not the role of MFD; system files may be stored separately.
  • none → Because "entries of user directories" is correct.

Question : Which of the following correctly describes access control in a tree-structured directory?

Solution :
482220260321075542 Correct Answer : Permissions like read, write, execute are assigned to users

Description -

The correct choice is Permissions like read, write, execute are assigned to users.

Brief Explanation

In a tree-structured directory system (the standard file system used by most modern operating systems), access control relies on a structured permission mechanism rather than giving everyone equal access or completely blocking everyone except the root user.

  • Granular Control: The system allows file owners or administrators to assign specific rights—typically Read (r), Write (w), and Execute (x)—to specific users, groups, or the general public.
  • Inheritance & Isolation: Because the directory is organized as a tree, permissions can be defined at higher directory levels or tailored individually for specific sub-directories and files, ensuring users can only access their authorized branches.

Question : In a tree-structured directory, the current working directory (CWD) is used to:

Solution :
107820260321075440 Correct Answer : Define relative paths

Description -

The correct choice is Define relative paths.

Brief Explanation

The Current Working Directory (CWD) acts as the user's or process's current location within the hierarchical file system.

  • Relative Paths: Instead of specifying a file's full location from the root directory (an absolute path, like /home/user/documents/report.txt), you can use a relative path that starts from your CWD (e.g., documents/report.txt or just txt if you are already inside the documents folder).
  • Efficiency: This saves time and typing, allowing the operating system to resolve file locations relative to where you currently are in the tree structure.

Question : Which limitation still exists in a tree-structured directory system?

Solution :
307120260321075358 Correct Answer : Difficulty in sharing files across directories

Description -

The correct choice is Difficulty in sharing files across directories.

Brief Explanation

While a tree-structured directory naturally organizes files into neat, isolated branches, it enforces a strict one-parent rule (each file or sub-directory lives under exactly one parent directory). This structure introduces a specific limitation:

  • Strict Isolation: Because of the rigid hierarchical tree, a file cannot naturally belong to two different folders at the same time.
  • Sharing Workarounds: To share a file across different directories, systems must use workarounds like creating duplicate copies (which wastes space and risks data desynchronization) or implementing links/shortcuts (like hard links or symbolic links). True, seamless sharing requires moving to an Acyclic Graph Directory

Question : Which feature of tree-structured directories improves search efficiency?

Solution :
712120260321075248 Correct Answer : Hierarchical grouping of files

Description -

The correct choice is Hierarchical grouping of files.

Brief Explanation

In a tree-structured directory, files are organized into a top-down, nested hierarchy of directories and sub-directories. This setup dramatically improves search efficiency for two primary reasons:

  • Reduced Search Space: Instead of scanning a massive, single flat list of every file on the system, the OS only searches the specific folder you point it toward.
  • Path-Based Navigation: The operating system follows a specific path branch by branch (e.g., Root ➔ Users ➔ Documents). By narrowing down the search area at each directory level, it ignores millions of unrelated files, locating your file almost instantly.

Question : In a tree-structured directory, which of the following best describes an absolute path?

Solution :
828120260321075200 Correct Answer : Path starting from root directory

Description -

The correct choice is Path starting from root directory.

Brief Explanation

An absolute path (also known as a full path) provides the complete location of a file or directory from the absolute beginning of the file system.

  • The Root Anchor: It always begins at the root directory (represented by a forward slash / in Unix/Linux or a drive letter like C:\ in Windows).
  • Independence: Because it starts from the root, an absolute path is completely independent of your current working directory (CWD). It will always point to the exact same file no matter where you are currently navigating in the tree structure.

Question : Which statement best differentiates acyclic graph directories from tree-structured directories?

Solution :
220720260321075000 Correct Answer : Acyclic allows multiple paths to same file, tree does not

Description -

The correct choice is Acyclic allows multiple paths to same file, tree does not.

Brief Explanation

The fundamental difference lies in how files can be linked and accessed within the system:

  • Tree-Structured Directories: Follow a strict parent-child hierarchy where each file or sub-directory can have exactly one parent. This means there is only one unique absolute path from the root directory to any given file.
  • Acyclic Graph Directories: Relax this rule by allowing directories to share files or sub-directories without creating duplicate copies. Because a shared file can have multiple parent directories, users can access the exact same underlying file using completely different path names (often implemented via shared links). It remains "acyclic" because loops or circular references are still strictly forbidden to avoid infinite searching.

Question : Which of the following problems is associated with acyclic-graph directory structures?

Solution :
786520260321074908 Correct Answer : Multiple path names (aliasing problem)

Description -

The correct choice is Multiple path names (aliasing problem).

Brief Explanation

While acyclic-graph directory structures successfully allow files and directories to be shared, they introduce specific complexities known as the aliasing problem:

  • Ambiguity (Aliasing): Because a single file can be linked to multiple parent directories, it can be referred to by multiple different path names.
  • Side Effects: If a user modifies the file under one path name, the changes instantly affect all other paths. This can confuse users who might not realize the file is shared.
  • Traversal and Deletion Issues: System utilities (like disk space calculators, backups, or search tools) might accidentally traverse the same shared file multiple times, leading to inaccurate counts. Furthermore, deleting the file becomes complicated—the system must decide whether to just remove the link or completely delete the underlying file using techniques like reference counters.

Question : In case of a hard link in an acyclic graph directory, when is the actual file deleted?

Solution :
319920260321074819 Correct Answer : When all references (links) are removed

Description -

The correct choice is When all references (links) are removed.

Brief Explanation

In an acyclic graph directory structure using hard links, the operating system tracks the file's existence using a reference counter (or link count) stored in the file's metadata (inode).

  • Reference Counting: Every time a new hard link is created for a file, the link count increases by 1. When a user deletes a hard link (often called an unlink operation), the system merely removes that specific directory entry and decrements the link count by 1.
  • Final Deletion: The actual file contents and disk space are only freed and deleted when the link count drops to zero, meaning absolutely no directories or paths point to that file anymore.

Question : What is the primary reason for restricting cycles in an acyclic-graph directory?

Solution :
241620260321074719 Correct Answer : To prevent infinite traversal loops

Description -

The correct choice is To prevent infinite traversal loops.

Brief Explanation

If cycles (circular references where a directory eventually points back to itself or an ancestor directory) are permitted, the structure becomes a general graph rather than an acyclic graph. This introduces severe computational problems:

  • Infinite Loops: Search algorithms, backup utilities, and disk space calculators traverse directories recursively. If a cycle exists, an ordinary search or backup tool could get caught in a never-ending loop, repeatedly scanning the same directories until the system crashes or runs out of memory.
  • Garbage Collection Issues: When files are deleted, determining whether the disk space can be safely freed becomes incredibly complex. Standard reference-counting mechanisms fail with cycles because the circular links keep the count above zero, even if the entire cycle is completely disconnected from the root directory.

Question : In an acyclic-graph directory structure, which of the following statements is correct?

Solution :
407320260321074623 Correct Answer : A file can have multiple parent directories through links

Description -

The correct choice is A file can have multiple parent directories through links.

Brief Explanation

An acyclic-graph directory structure is explicitly designed to overcome the strict "one parent per file" limitation of a standard tree-structured directory.

  • Shared Access: It allows a single physical file or sub-directory to be shared across different folders. This means the exact same file can have multiple parent directories and can be accessed via entirely different path names.
  • No Duplication: This sharing is achieved using mechanisms like links (shortcuts or references) without duplicating the actual file contents on the disk, saving storage space and ensuring updates are visible across all access paths.
  • No Cycles: As the name implies, cycles (loops) are strictly forbidden to prevent infinite traversal bugs during file searches or system backups.