Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

What are tree-structured directories?

Khizar Hayat Saani

A directory refers to a container that stores and organizes files and folders in a system.

There are several ways to structure a directory. However, tree-structured directories are the most common.

Tree-structured directory

Structure

The directory is structured in the form of a tree. It also has a root directory, and every file in the system has a unique path.

A directory within a tree-structured directory may contain files or subdirectories. Special system calls are used to create or remove directories.

One bit in each directory entry is used to identify the entry as either a file (represented by ‘0’) or a directory (represented by ‘1’).

Tree-structured directory

Users

Each user has their own directory and cannot access the directory of another user. All users can read data from the root directory. However, they cannot write to or modify the root directory. This privilege is reserved for the system administrator who has complete access to the root directory.

User directories

Paths

We can access a file using two types of paths. These are:

  • Absolute path
  • Relative path

The absolute path is the path to the file with respect to the root directory.

The relative path is the path to the file with respect to the current working directory.

Path Types

Consider the above directory tree. Let’s assume that the current working directory is: root/home/Desktop.

To access the file under the directory labeled Edpresso, we can use the following paths:

  • Relative path: Edpresso

  • Absolute path: root/home/Desktop/Edpresso

Advantages

A tree-structured directory is very general because every file can be accessed using its absolute path.

It is also very scalable since we can easily create or remove directories and subdirectories. This also reduces the probability of name collisions within a directory.

Tree-structured directories also allow for easier searching, as we can use both the absolute or relative paths for a file.

Disadvantages

Tree-structured directories do not allow file sharing between users.

They are also inefficient in the sense that accessing a file may force you to go under multiple directories.

Advantages

Disadvantages

General

Inefficient

Scalable

No file sharing

Easy to Seacrh

File duplication in multiple directories

RELATED TAGS

CONTRIBUTOR

Khizar Hayat Saani
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring