简体   繁体   English

Avl树和红黑树的比较

[英]Comparison of Avl Tree and Red Black Tree

I have an exam tomorrow and there are 3 questions those i can not understand on my notes. 明天我要参加考试,笔记中有3个我无法理解的问题。

1- #searches >> #insertions and #deletions=0 Which tree is that? 1-#搜索>>#插入和#删除= 0那是那棵树? (Avl or Red-Black Tree) (Answer is Avl) (Avl或红黑树)(答案为Avl)

2- #insertions>0 and #searches=#deletions=0 Which tree is that? 2- #insertions> 0和#searches =#deletions = 0那是哪棵树? (Avl or Red-Black Tree) (Answer is Red-Black) (Avl或红黑树)(答案是红黑)

3- #insertions=#deletions and #searches=0 Which tree is that? 3-#insertions =#deletions和#searches = 0那是哪棵树? (Avl or Red-Black Tree) (Answer is Red-Black) (Avl或红黑树)(答案是红黑)

Can you explain them please? 你能解释一下吗? Thanks for help 感谢帮助

AVL trees, compared to red/black trees, usually have smaller height because the AVL invariants give less room for imbalance. 与红色/黑色树相比,AVL树通常具有较小的高度,因为AVL不变量为不平衡提供的空间较小。 However, red/black trees, compared to AVL trees, have faster insertions and deletions (the fixup cost of maintaining the red/black invariants is lower than the fixup cost of maintaining the AVL invariants.) 但是,与AVL树相比,红色/黑色树的插入和删除速度更快(维护红色/黑色不变式的固定成本低于维护AVL不变式的固定成本。)

For case (1), an AVL tree is probably better because the cost of the lookups will be lower and, if the number of lookups is truly much larger than the number of insertions, the AVL tree will have a comparative advantage. 对于情况(1),AVL树可能更好,因为查找的成本会更低,并且如果查找的数量确实比插入的数量大得多,则AVL树将具有比较优势。

For case (2), the red/black tree will probably be faster because it supports faster insertions. 对于情况(2),红色/黑色树可能会更快,因为它支持更快的插入。

For case (3), for the same reason as part (2), the red/black tree will probably be faster. 对于情况(3),由于与第(2)部分相同的原因,红色/黑色树可能会更快。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM