随笔 - 50  文章 - 8  trackbacks - 0
<2010年3月>
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

常用链接

留言簿

随笔档案

Blogs

搜索

  •  

最新评论

阅读排行榜

评论排行榜

5.1 Balancing Rule

A binary search tree is an AVL tree if the difference in height between the subtrees of each of its nodes is between -1 and +1. Said another way, a BST is an AVL tree if it is an empty tree or if its subtrees are AVL trees and the difference in height between its left and right subtree is between -1 and +1.

Here are some AVL trees:

[Click here for plain-text rendering]

These binary search trees are not AVL trees:

[Click here for plain-text rendering]

In an AVL tree, the height of a node's right subtree minus the height of its left subtree is called the node's balance factor (see balance factor). Balance factors are always -1, 0, or +1. They are often represented as one of the single characters -, 0, or +. Because of their importance in AVL trees, balance factors will often be shown in this chapter in AVL tree diagrams along with or instead of data items. Here are the AVL trees from above, but with balance factors shown in place of data values:

[Click here for plain-text rendering]

See also: [Knuth 1998b], section 6.2.3.

posted on 2010-10-05 01:38 sohu2000000 阅读(799) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航:   博客园   博客园最新博文   博问   管理