Difference between red-black trees and AVL trees

前端 未结 9 709
温柔的废话
温柔的废话 2020-12-07 08:46

Can someone please explain what the main differences between these two data structures are? I\'ve been trying to find a source online that highlights the differences/simila

9条回答
  •  孤城傲影
    2020-12-07 09:24

    The max height of the trees is the paramount important to keep balance. It almost equals 1.44 * log(n) for AVL, but for RB tree, it is 2 * log(n). So we can get the conclusion that it is better to use the AVL when the problem is search incentive. What matters is another question for AVL and RB tree. RB tree is better than AVL when facing the random insertion at the lower cost of the rotation but the AVL that is good to insert the ascending or descending datas. So if the problem is insertion incentive, we can use RB tree.

提交回复
热议问题