I want to implement a data structure that will hold the paths of directories, sort of fake file system.
Input:- I have a text configuration file containing the paths as follows
…
C:/temp1
C:/temp1/insideTemp1
C:/temp2/
…
I might end up storing huge amount of paths inside the data structure and I am looking for extremely low retrial time.
Here are the data structures that I think might be useful in this situation :-
B tree
B+ tree
Wavelet Tree
Trie
and B-Trie
I am not sure what data structure would be best useful in this situation.
I am not familiar with the B-trie, nor there are much resources on the internet that I can find that would help me in implementing and understanding one, but I think this might be a good choice for implementation considering it would have advantages of both b tree and trie, correct me if I am wrong.
I would like to know what would be the good data structure in implementing this problem and if you can redirect me some resource that would help me to get started that would be great!
Also, just out of curiosity, in the future if I want to expand the suggested data structure towards full-fledged file system would the suggested data structure be good enough to expand?
Every answer is appreciated.
Best Answer
Quick Short Answer
Pick a regular Tree Structure first, later look for a similar optimized version
Long Boring Extended Answer
Use a regular Tree Structure first.
I read that it seems you try to store the entire path in each node element, and that's one of the reasons your structure may requiere unnecesarily optimization.
Note: The following examples are pseudocode. These are not specific Programming Language, finished examples.
Instead of having something like these:
You may want to have something like these:
You didn't specify a particular Programming Language in your question. Neither if you are using an Imperative, Procedural, Functional or Object Oriented P.L., that may help suggest you a library.
Cheers.