0% found this document useful (0 votes)
76 views

INITO Assignment

This document discusses implementing a file system in memory using a tree data structure. It recommends using a tree rather than a binary tree because trees can have a variable number of child nodes like directories. It suggests using a binary tree-like structure where each node has two links - one to its first child and one to its parent. This allows traversing and implementing directory operations like changing directories, listing files, creating/removing nodes, and copying/moving files in time complexities of O(m*h) where m is the number of nodes in a directory and h is the tree height. The node structure and operations are explained in detail.

Uploaded by

Manish Kumawat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
76 views

INITO Assignment

This document discusses implementing a file system in memory using a tree data structure. It recommends using a tree rather than a binary tree because trees can have a variable number of child nodes like directories. It suggests using a binary tree-like structure where each node has two links - one to its first child and one to its parent. This allows traversing and implementing directory operations like changing directories, listing files, creating/removing nodes, and copying/moving files in time complexities of O(m*h) where m is the number of nodes in a directory and h is the tree height. The node structure and operations are explained in detail.

Uploaded by

Manish Kumawat
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

INITO IN-Memory

File system
What
WhatisisFile
Filesystem??
system?? INITO
How to Approch INITO

selection of suitable data structure

Tree
Trees are the best suitable data structure to implement this
because nodes and leaves of the tree resemble the directories
and sub-directories containing files in them.
A binary tree cannot do the job here as it restricts to only
why tree ?? why not
having two children. N-ary Tree should be implemented solve
binary tree???....
this. Since we do not know what will be the value of n, each
node cannot have a fixed child links.

But if we think that keeping the contents of a directory as a


linked list and only storing the first child’s address, then each
node can have exactly 2 links. This makes it possible to use
algorithms of Binary Tree as well.

INITO
We also a need to traverse upwards to its root. That can be solved by
creating another link with the parent directory. Although this technically INITO
becomes a Graph, but implementation will be like a binary tree in a broad
level and like linked list in a directory level.
Get to Know Them

Structure
of Node

INITO
predefined
Structure
of
directories

INITO
Create a new node
for Directory/File
{Mkdir/touch}

Time complexity of creating


node
Time Complexity = O(m*h)
Auxiliary Space = O(1)
where,
n = Total number of nodes
m = number of nodes in a directory INITO
h = height of tree
To Remove
file/directorie
rm or rmdir

Time complexity of
Remove/delete a node
Time Complexity = O(m*h)
Auxiliary Space = O(1)
where,
n = Total number of nodes
m = number of nodes in a directory INITO
h = height of tree
change directory
{cd}

Time complexity of creating


node
Time Complexity = O(m*h)
Auxiliary Space = O(h)
where,
n = Total number of nodes
m = number of nodes in a directory INITO
h = height of tree
print curr.
INITO
working directory
{pwd}
Time complexity of pwd
Time Complexity = O(h)
Auxiliary Space = O(h)
where,
n = Total number of nodes
m = number of nodes in a directory
h = height of tree

print list of all


directory
{ls}
Time complexity of ls
Time Complexity = O(m)
Auxiliary Space = O(1)
where,
n = Total number of nodes
m = number of nodes in a directory
h = height of tree
To Display file
content
{cat}

Time complexity
Time Complexity = O(m*h)
Auxiliary Space = O(1)
where,
n = Total number of nodes
m = number of nodes in a directory
h = height of tree INITO
To copy
file/move file
cp/mv

Time complexity of
Remove/delete a node
Time Complexity = O(m*h)
Auxiliary Space = O(1)
where,
n = Total number of nodes INITO
m = number of nodes in a directory
h = height of tree
INITO

Thank you !!
Have a Nice Day!!!

You might also like