Computer Science, asked by legionbhaiya, 7 months ago

Balanced System Files Partition::

The directory structure of a system disk partition is
represented as a tree. Its n directories are numbered
from 0 to n-1, where the root directory has the
number 0. The structure of the tree is defined by a
parent array, where parent[i] = j means that the
directory i is a direct subdirectory of j. Since the root
directory does not have a parent, it will be
represented as parent[0] = -1. The value
in files_size[i] denotes the sum of the sizes in
kilobytes of the files located in directory i, but
excluding its subdirectories. The size of the content
of a directory is defined as the size of all files
contained in this directory, plus the sum of the sizes
of all of its subdirectories. Partition the tree into two
smaller ones by cutting one branch so that the sizes
of the resulting subtrees are as close as possible.
Example
parent = [-1, 0, 0, 1, 1, 2]
files size[ 1 ,2, 2, 1 ,1 ,1 ]​

Attachments:

Answers

Answered by aaravs618gmailcom
0

Answer:

Structures of Directory in Operating System

A directory is a container that is used to contain folders and file. It organizes files and folders into a hierarchical manner.

There are several logical structures of a directory, these are given below.

Single-level directory –

Single level directory is simplest directory structure.In it all files are contained in same directory which make it easy to support and understand.

A single level directory has a significant limitation, however, when the number of files increases or when the system has more than one user. Since all the files are in the same directory, they must have the unique name . if two users call their dataset test, then the unique name rule violated.

Advantages:

Since it is a single directory, so its implementation is very easy.

If the files are smaller in size, searching will become faster.

The operations like file creation, searching, deletion, updating are very easy in such a directory structure.

Disadvantages:

There may chance of name collision because two files can not have the same name.

Searching will become time taking if the directory is large.

In this can not group the same type of files together.

Two-level directory –

As we have seen, a single level directory often leads to confusion of files names among different users. the solution to this problem is to create a separate directory for each user.

In the two-level directory structure, each user has there own user files directory (UFD). The UFDs has similar structures, but each lists only the files of a single user. system’s master file directory (MFD) is searches whenever a new user id=s logged in. The MFD is indexed by username or account number, and each entry points to the UFD for that user.

Advantages:

We can give full path like /User-name/directory-name/.

Different users can have same directory as well as file name.

Searching of files become more easy due to path name and user-grouping.

Disadvantages:

A user is not allowed to share files with other users.

Still it not very scalable, two files of the same type cannot be grouped together in the same user.

Answered by Anonymous
0

Answer:

Thanks for answering my questions

Similar questions