文章目录
红黑树与AVL树的区别
红黑树的一个案列
- Root is always black.(根结点是黑的。)
- All NULL leaves are black, both children of red node are black and vice-versa.(每一个叶子节点,NIL都是黑色)
- Every simple path from a given node to any of its descendant leaves contains the same number of black
nodes.(对于每一个节点,从该节点到叶子节点路径上面的黑节点数目是一样的) - Path form root to farthest leaf is no more than twice as long as path from root to nearest leaf.
每一个NIL是黑色的,使用矩形表示,非叶子节点采用圆形表示
英文答案
AVL trees maintain a more rigid balance than red-black trees. The path from the root to the deepest leaf in an AVL tree is at most ~1.44 lg(n+2), while in red black trees it’s at most ~2 lg (n+1).