What is the best algorithm to use in creating binary trees?
I've been doing a research about the best algorithm to use in creating a binary tr开发者_运维技巧ee implementation. THe top entry in my list is nested sets. Are there any other alternative or better algorithm??
If possible can you give me a list of top algorithms so that I can research/study it and see if it will fit the system needs.
Quite simply, it depends on what you are going to use it for.
- Is it important to do insertions, updates and/or deletes fast?
- Will you any specific out-of-the-ordinary operations on the tree?
- How much data will there be in the tree?
- Do you have to store it in a database or just in memory?
And so on..
For example, using a nested set is not really a good choice if the most important operation is: "given a node, find it's grandfather".
Also, you could leverage the fact that you want a binary tree. The nested set model can be used to describe any tree and doesn't really use the fact that it's binary.
精彩评论