Come up with a config (Data Structure) and load a new directory tree from config. Write a program that does flowing operations on a directory tree. Add a new folder at a particular path in the directory tree. Removed a folder from a particular path in the directory tree. Fetch the path of the given folder. Update name of the folder.
Note: For each folder we should have unique id
and name
.
Also upload the program on github and share the link with README.
pip install pprint
pip install uuid
- python main.py
- Add node -> Add a new node to the data structure bu specifying its immediate parent node and new node name
- Delete node -> Enter name of node to be deleted (All of its children are deleted too)
- Rename node -> specify new and old name for a node and it gets renamed
- Fetch node path -> Beginning from the root node the full path of the node is printed
- Print tree -> the tree structure is printed
- EXIT > exit program
Used multiple data structures to maintain all info.
Edge case 1 - All folders must be uniquely named
soln - could change the whole structure to nested dicts
Used a single more elegant data structure.
Assumption -
Fetch Method : Currently printing the first folder which is found in tree.
Potential solutions:
- Pass id along ith name and find the specific folder.
- Find all folder having that name instead of the first.