我应该使用什么树结构来建立索引?

发布于 2024-09-27 02:55:45 字数 187 浏览 7 评论 0原文

我正在考虑尝试使用树结构进行索引,因为我想测试它是否比我当前的索引实现(本质上是基于哈希的查找)更快。

我阅读了有关 B 树、AVL 树和红黑树性能的各种问题和文章,但实际上看不出它们在性能方面有多大区别。

人们会推荐什么树结构,为什么?理想情况下,它应该有一个可用的现有 .Net 实现,尽管我并不反对在必要时实现我自己的实现

I'm thinking of experimenting with using a tree-structure for indexing as I want to test whether it is faster than my current indexing implementation which is in essence a hash based lookup.

I've read up on various questions and articles about performance of B-Trees, AVL-Trees and Red-Black Trees and can't really see much difference between them performance wise.

What tree structure would people recommend and why? Ideally it should have an existing .Net implementation available though I'm not averse to implementing my own if necessary

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼泪都笑了 2024-10-04 02:55:45

一个好的哈希表几乎总是比树更快。树的最大优点是您可以使用它来查询范围和排序。因此,如果您不需要这些功能,我宁愿考虑优化基于哈希的解决方案。

并且 AFAIK SortedDictionary 是基于树的。

A good hashtable is almost always faster than a tree. The great advantage of the tree is that you can use it to query ranges and for ordering. So if you don't need these features I'd rather look into optimizing your hash based solution.

And AFAIK SortedDictionary<K,V> is tree based.

蓝色星空 2024-10-04 02:55:45

二叉树不是平衡的。不要使用它。

AVL树比红黑树具有更好的平衡性;它有更快的查找速度。

更重要的是,AVL 算法简单易懂。 IME 并不是红黑算法的情况。你无法实现你不理解的算法,或者更确切地说,你可以盲目地实现它们,在我看来,这完全等同于无法实现它们。

A binary tree is not balanced. Do not use it.

An AVL tree is better balanced than a red-black tree; it has faster lookup.

Much more importantly, the AVL algorithm is straightforward and comprehendable. This is, IME, not the case for the red-black algorithm. You cannot implement algorithms you do not understand, or rather, you can implement them blindly, which is properly tantamount in my view to -not- being able to implement them.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文