zoukankan      html  css  js  c++  java
  • 数据结构与算法(C#实现)系列AVLTree(二)(外摘)

    数据结构与算法(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;}}
            
    }
  • 相关阅读:
    python 3 day1(上)
    JMeter (一) Thread Group
    TC-001下载并简单使用Python
    SQL Server ->> 谈SQL Server数据库大表迁移
    SQL Server ->> 记Alwayson高可用副本同步失败后续恢复的性能调优争议
    SQL Server ->> AlwaysOn高可用副本同步失败
    SQL Server ->> AlwaysOn 监控脚本
    Linux ->> Source命令
    PSD 转化成 HTML
    笔试
  • 原文地址:https://www.cnblogs.com/HondaHsu/p/710797.html
Copyright © 2011-2022 走看看