六月婷婷综合激情-六月婷婷综合-六月婷婷在线观看-六月婷婷在线-亚洲黄色在线网站-亚洲黄色在线观看网站

明輝手游網(wǎng)中心:是一個免費(fèi)提供流行視頻軟件教程、在線學(xué)習(xí)分享的學(xué)習(xí)平臺!

數(shù)據(jù)結(jié)構(gòu)與算法(C#完成)---AVLTree(一)

[摘要]using System;using System.Collections;namespace DataStructure /// <summary> /// AVLTree 的摘要說明。-----平衡二叉查找樹 /// </summary> pub...

using System;
using System.Collections;namespace DataStructure
{
    /// <summary>
    /// AVLTree 的摘要說明。-----平衡二叉查找樹
    /// </summary>
    public class AVLTree:BST
    {
        protected int height;//空樹的高定義為-1;
       
 //構(gòu)造一棵空的二叉查找樹
        public AVLTree():base()
        {
            //
            // TODO: 在此處添加構(gòu)造函數(shù)邏輯
            //
            height=-1;
         }         public AVLTree(object _obj):base(_obj)
         {
             height=0;
         }         //------------------------------------------------------
         protected override object GetEmptyInstance(uint _degree)
         {
      return new AVLTree();
  }
         //------------------------------------------------------         protected int BalanceFactor()
         {
             if (this.IsEmpty() )
                 return 0;
             return ((AVLTree)this.Left).height-((AVLTree)this.Right).height;
          }          //調(diào)整高度
         protected void AdjustHeight()
  {
      this.height=Math.Max( ((AVLTree)this.Left).height, ((AVLTree)this.Right).height)+1;
  }         //平衡時的四種旋轉(zhuǎn)方式
         protected void LLRotation()
         {
             if( this.IsEmpty() )
                 throw new Exception("My:invalid operation!");
             AVLTree avlB=new AVLTree(this.key);
             avlB.AttachSubtree(1,(AVLTree)this[0][1]);
             avlB.AttachSubtree(2,(AVLTree)this[1]);             this.key=this[0].Key;
             this[0]=this[0][0];
             this[1]=avlB;
             //調(diào)整兩個節(jié)點(diǎn)的高度
             ((AVLTree)this.Right).AdjustHeight();
             this.AdjustHeight();
          }          protected void LRRotation()
          {
              if( this.IsEmpty() )
              throw new Exception("My:invalid operation!");
              ((AVLTree)this.Left).RRRotation();
              this.LLRotation();
          }
 
          protected void RRRotation()
          {
              if( this.IsEmpty() )
                  throw new Exception("My:invalid operation!");
              AVLTree avlB=new AVLTree(this.key);
 
              avlB.AttachSubtree(1,(AVLTree)this[0]);
              avlB.AttachSubtree(2,(AVLTree)this[1][0]);              //avlA.AttachSubtree(1,avlB);
 
              //this=avlA;
              this.key=this[1].Key;
              this[0]=avlB;
              this[1]=this[1][1];
              //調(diào)整兩個節(jié)點(diǎn)的高度
              ((AVLTree)this.Left).AdjustHeight();
              this.AdjustHeight();
           }           protected void RLRotation()
           {
               if( this.IsEmpty() )
                  throw new Exception("My:invalid operation!");
               ((AVLTree)this.Right).LLRotation();
               this.RRRotation();
           }


主站蜘蛛池模板: 青青草原在线免费 | 亚洲综合15p | 亚洲网站色 | 在线视频第一页 | 亚洲人与牲动交xxxxbbbb | 一级毛片一级毛片一级毛片aaav | 四虎自拍 | 最近最中文字幕视频 | 亚洲第一性网站 | 日韩无毛| 色噜噜在线观看 | 欧美在线香蕉在线现视频 | 欧美一区不卡二区不卡三区 | 日本高清视频在线免费观看 | 色色网视频| 视频一区二区三区在线观看 | 我要看黄色一级毛片 | 四月婷婷 | 四虎激情做人爰 | 香蕉久人久人青草青草 | 亚洲精品网站日本xxxxxxx | 在线视频二区 | 天堂在线观看中文字幕 | 午夜手机福利视频 | 欧美在线xx | 青青草视频官网 | 日韩在线视频播放 | 性久久久久久久久久 | 日韩私人影院 | 亚洲最大成人网 色香蕉 | 一级毛片免费高清视频 | 亚洲影院国产 | 四虎在线播放免费永久视频 | 四虎影视免费 | 星辰影院在线观看 | 亚洲欧美日韩三级 | 亚洲天堂影视 | 亚洲精品国产精品乱码不卞 | 亚洲国产99在线精品一区二区 | 日韩一区二区精品久久高清 | 日韩精品视频美在线精品视频 |