Download as pdf or txt
Download as pdf or txt
You are on page 1of 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