• Welcome to the world's largest Chinese hacker forum

    Welcome to the world's largest Chinese hacker forum, our forum registration is open! You can now register for technical communication with us, this is a free and open to the world of the BBS, we founded the purpose for the study of network security, please don't release business of black/grey, or on the BBS posts, to seek help hacker if violations, we will permanently frozen your IP and account, thank you for your cooperation. Hacker attack and defense cracking or network Security

    business please click here: Creation Security  From CNHACKTEAM

Recommended Posts

基于二叉查找树对平衡二叉树进行优化。

二叉查找树有时左右倾斜度很大,如下图所示。在搜索元素6的时候,会搜索六次,和直接用链表是一样的,所以搜索效率会变低。通过用一些规则对树进行重新排序,将直接平衡节点,从而改善效率低下的问题。

image

image

平衡因子:左子树深度-右子树深度,如上图所示,叶子节点没有左右子树,所以为0,元素2的左子树深度为1,但是没有0,1-0=1的子树。

当平衡系数大于1时,二叉查找树应该是平衡的。

LL情况

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now