数据结构与算法(C#实现)系列---AVLTree(二)
2008-04-24 10:24
411 查看
数据结构与算法(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;}} }
相关文章推荐
- 数据结构与算法(C#实现)系列---AVLTree(二)
- 数据结构与算法(C#实现)系列---AVLTree(二)(外摘)
- 数据结构与算法(C#实现)系列---树(二)
- 数据结构与算法(C#实现)系列---N叉树(二) _C#教程
- 数据结构与算法(C#实现)系列---广义树(一)_C#教程
- 数据结构与算法(C#实现)系列---广义树(一)_C#教程
- 数据结构与算法(C#实现)系列---N叉树(一)_C#教程
- 数据结构与算法(C#实现)系列---树(三)
- 数据结构与算法(C#实现)系列---树(三)
- 数据结构与算法(C#实现)系列-----前言_C#教程
- 数据结构与算法(C#实现)系列---演示篇(二)_C#教程
- 数据结构与算法(C#实现)系列---N叉树(二) _C#教程
- 数据结构与算法(C#实现)系列---N叉树(一)_C#教程
- 数据结构与算法(C#实现)系列
- 数据结构与算法(C#实现)系列---演示篇(一)
- 数据结构与算法(C#实现)系列---树(二)
- 数据结构与算法(C#实现)系列---广义树(一)
- 数据结构与算法(C#实现)系列---演示篇(三)_C#教程
- 数据结构与算法(C#实现)系列---演示篇(二)_C#教程
- 数据结构与算法(C#实现)系列---广义树(二)_C#教程