哪个更快:“基数树”或“b树”
对于处理语言,如常规字典单词,基数树或常规 B 树哪个读取速度更快?有没有更快的方法,例如带有 Bucket & 的字典?散列?
For processing language, as in regular dictionary words, which would be faster at reading, a radix tree, or a regular b-tree? Is there a faster method, such as a dictionary with buckets & hashing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
与往常一样,您需要在应用程序上下文中进行基准测试才能确定。
然而,我预计在这种情况下,实现良好的哈希表可能会被证明是最快的。这基本上需要:
基数树也会非常快,由于需要遍历多个级别的树节点,因此只会有一点额外的开销。如果您的树相对稀疏,则查找可能只需要向下进行少量级别即可找到唯一的答案。基数树的一个优点是,如果没有可能的匹配项,它会很早就告诉您(例如,以“qq”开头的树的空分支)
二叉树可能是最慢的,因为它平均需要搜索通过相当多级别的树节点。然而对于大多数用途来说它仍然足够快。
As always, you will need to benchmark in your application context to be sure.
However, I expect that in this case a well-implemented hash table will probably prove to be fastest. This basically requires:
A radix tree will also be very fast, there is just a little bit of extra overhead due to the need to traverse multiple levels of tree nodes. If your tree is relatively sparse, it's likely that may lookups will only need to go down a small number of levels to find a unique answer. One advantage of the radix tree is that it will tell you very early if you have no possible matches (e.g. an empty branch for the tree starting with "qq")
A binary tree will probably be the slowest since it will on average have to search through quite a few levels of tree nodes. However it will still be fast enough for most purposes.