Cisco Systems Interview Question
Software DevelopersCountry: United States
Interview Type: In-Person
I think you can do more to explain yourself and you will probably want to re-read the question. The question asks which data structure is well suited for commands like pwd, ls, mkdir, cd. It also asks to explain.
FileSystems are complex components built up of many different data structures but trees are most commonly used to describe them because of their hierarchical nature. Trees are easy to understand and map logically to contents of files and folders on a disk. Each node in a tree may have additional data about the item that is stored there. Some OSs use a b-tree, b+tree, or other specialized tree structure, the point here isn't to over-optimize the answer but to discuss the trade-offs about the structure.
For example, in your case of using symbolic links we may just need to say, when using a tree, the symbolic link is duplicated in the tree structure elsewhere and has a reference to the node for the original. The drawback is you have duplicated data. The benefit is it's still simple to think about and fits without a lot of extra effort.
If I were asking this question... and I have... I'm looking for a discussion, not a drop-the-mic moment.
A graph.
- NoOne September 04, 2017yes. You heard that right. FileSystem is not a tree. Never was. The moment you invented the notion of [ askubuntu.com/questions/108771/what-is-the-difference-between-a-hard-link-and-a-symbolic-link ] - tree is dead. Long live the graph.
And we are done.