$24
Objective
All of the files in the UNIX file system are organized into a multi-leveled hierarchy called a directory tree. A family tree is an example of a hierarchical structure that represents how the LINUX file system is organized. The LINUX file system might also be envisioned as an inverted tree or the root system of plant.
At the very top of the file system is single directory called "root" which is represented by a / (slash). All other files are "descendents" of root.
In this exercise, we will construct a S tree data structure to store the directory and file names in a hierarchical manner so that the search of a directory/file can be efficiently. Input data will be provided as form of a file containing the list of directories/file names along with their other attributes addresses.
Input format
Each line will start with a one of the following key values (1, 2, or -1). Each key corresponds to a function and has a pattern. Implement following function according to given pattern and write a driver function which can call the functions according to given key value.
Ke
Function
to
Input Format
Description
y
call
1
readData
1 N
Read next N lines having a paths in each line. “path” will be
path1
a system path of a file or directory (containing all lower case
path2
letters and arbitrary number of slashes). Keep inserting
…..
each path in a tree as mentioned above.
pathN
1 | P a g e
2
lookup
2 name
search for “path” in the tree. Print YES if it is present, NO
otherwise.
-1
stop the program.
Test Case 1:
Input
Output
1 10
/bin
/dev
/etc
/home
/lib
/usr
/var
/dev/fd
/dev/hd
/dev/tty
/usr/saiyedul
/user/jagat
2 /dev/fd
2 /usr/ashutosh
-1
2 | P a g e