Course Content
Bonus Section (for Interviews and GATE/Placement prep)
0/1
Operating Systems (OS)
Directory Structures

A directory structure organizes and manages the files on a storage device by grouping related files together. It determines how files are named, stored, and retrieved, and how the user navigates between different files or directories in a system. Various directory structures offer different levels of complexity, flexibility, and efficiency depending on the system’s design and user requirements.


Single-Level Directory

In a single-level directory structure, all files are stored in one directory, regardless of which user created them. Every file must have a unique name, as there is no separation based on user or project.

 

This structure is easy to understand and implement, making it suitable for simple operating systems or personal computers with a small number of files.

However, it lacks scalability and becomes disorganized quickly when the number of files increases, making it inefficient for multi-user or large-scale systems.


Two-Level Directory

To overcome the limitations of single-level structures, two-level directories separate each user’s files into their own user directory. There is a master directory that contains an entry for each user, and each user has their own subdirectory where they store files.

 

This model supports multiple users without file name conflicts. A user can have files with the same name as another user, because they exist in separate user directories.

However, it does not allow users to organize their own files into categories or folders, limiting file management capabilities within the user’s directory.


Tree-Structured Directory

The tree structure extends the two-level model by allowing each user to create arbitrary subdirectories within their own directory. These subdirectories can further contain files or more subdirectories, forming a hierarchical tree structure.

 

This model closely resembles file systems in modern operating systems like Windows, macOS, and Linux.

It allows better file organization, grouping, navigation, and management, enabling users to create project-specific folders or sort files by type or date. File paths become longer, but more meaningful, as they reflect the hierarchy from root to file.


Acyclic Graph Directory

An acyclic graph directory extends the tree structure by allowing a file or subdirectory to appear in more than one parent directory, through the use of links or shortcuts.

 

This approach allows shared files or folders, often used in collaborative environments where multiple users need access to the same data without duplication.

The structure must remain acyclic (i.e., no loops are allowed), so the system can perform file traversal without ending up in infinite cycles. Proper handling of deletion and updates becomes important to maintain consistency and avoid dangling links.

0% Complete
WhatsApp Icon

Hi Instagram Fam!
Get a FREE Cheat Sheet on System Design.

Hi LinkedIn Fam!
Get a FREE Cheat Sheet on System Design

Loved Our YouTube Videos? Get a FREE Cheat Sheet on System Design.