0

I have a hierarchical data structure. There is not much addition, deletion done to this structure, its mostly for reading and searching. I'm trying my best to find a good data structure to store this data to enable fast searching. All the examples/tutorials I have seen talk about some form of binary tree. Is there a data structure (tree) that will enable me to model this effectively. An alternative form I can think of is to use a graph, but I'm not sure about that.

tmp dev
  • 8,043
  • 16
  • 53
  • 108

1 Answers1

0

B-Tree will be the best choice for your description because of its amazing performance in "reading and searching", it will enable you achieve log(n) for insertion/deletion/search, beside it's a cache friendly so you will get the minimum number of cache misses.

  • I did come across this but I'm having trouble figuring out how to implement this practically. All the examples I have seen out there talk about databases, and I am having trouble applying this practically – tmp dev Mar 01 '22 at 21:45
  • "https://github.com/islamwagih/B-Tree-/blob/master/main.cpp" This is my implementation of B-Tree, I hope you found it useful but I recommend you to understand B-tree theoretically before going for the implementation – Islam wagih Mar 02 '22 at 17:14
  • thanks, one of the main points in b trees are the degree/order. How do I figure out an optimal value for this, most of the documentation/examples seem to pick an arbitary number from what I can see ? – tmp dev Mar 03 '22 at 00:46
  • it depends on the context of the problem, in case you are not sure what order to choose you can generally use order 5-10 and you can refer this it may help "https://stackoverflow.com/questions/28677734/how-to-decide-order-of-a-b-tree#:~:text=As%20you%20said%2C%20B%20Trees,field%20size%20and%20pointer%20size." – Islam wagih Mar 03 '22 at 11:51