数据结构与算法(C#实现)系列---AVLTree(二)
//---------------override--------------------
public override void AttachKey(object _obj)
{
if(!IsEmpty())
throw new Exception("My:this node must be a empty tree node!");
this.key=_obj;
//产生一个degree长的数组,并将其初始化为空树
this.treeList=new ArrayList();
this.treeList.Capacity=(int)this.degree;
for(int i=0;i<this.degree;i++)
{
treeList.Add(new AVLTree());
}
//
this.height=0;
}
//在改动树的结构后平衡树
public override void Balance()
{
this.AdjustHeight();
//大于1则说明不平衡
if( Math.Abs(this.BalanceFactor())>1)
{
if(this.BalanceFactor()>0)
{
if (((AVLTree)this.Left).BalanceFactor()>0)
this.LLRotation();
else
this.LRRotation();
}
else
{
if (((AVLTree)this.Right).BalanceFactor()<0)
this.RRRotation();
else
this.RLRotation();
}
}
}
public int Height{get{return this.height;}}
}
| QQ分组 | 淘宝群发 | QQ空间代码大全 | asp教程svn用法教程 | asp.net教程php教程 | 枕木 | 360编程教程网 | 多功能小吃车 | 武汉网站优化 |
| 友情链接平台 | 背背佳官方网站 | 您的位置 | 您的位置 | 您的位置 | 您的位置 | 您的位置 | 您的位置 | 您的位置 |
| 关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助中心 |
| Copyright 2006-2008 Powered by 360Coding.com,360编程教程网All Rights Reserved. E-Mail: 广告服务QQ:582044*** 本站资源来自原创和网络整理,如有侵权请通知本人,将尽快删除 |