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

明輝手游網中心:是一個免費提供流行視頻軟件教程、在線學習分享的學習平臺!

數據結構與算法(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;
       
 //構造一棵空的二叉查找樹
        public AVLTree():base()
        {
            //
            // TODO: 在此處添加構造函數邏輯
            //
            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;
          }          //調整高度
         protected void AdjustHeight()
  {
      this.height=Math.Max( ((AVLTree)this.Left).height, ((AVLTree)this.Right).height)+1;
  }         //平衡時的四種旋轉方式
         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;
             //調整兩個節點的高度
             ((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];
              //調整兩個節點的高度
              ((AVLTree)this.Left).AdjustHeight();
              this.AdjustHeight();
           }           protected void RLRotation()
           {
               if( this.IsEmpty() )
                  throw new Exception("My:invalid operation!");
               ((AVLTree)this.Right).LLRotation();
               this.RRRotation();
           }


主站蜘蛛池模板: 欲色影视 | 四虎网址在线 | 日韩激情淫片免费看 | 亚洲视频免费观看 | 日韩最新中文字幕 | 青青青青草原国产免费 | 婷婷五色 | 四虎国产精品免费观看 | 亚洲成a人片在线观看播放 亚洲成a人片在线观看www | 日本午夜三级 | 亚洲国产毛片aaaaa无费看 | 亚洲欧美精品一区二区 | 天天操天天看 | 亚洲天堂三级 | 手机看片日韩日韩韩 | 在线不欧美 | 日本免费一区二区三区视频 | 亚洲精品有码在线观看 | 天天操2018| 四虎影视在线影院4hutv | 色美女影院 | 亚洲精品福利在线观看 | 最好韩国日本高清免费 | 天天色天天干天天 | 亚欧乱色精品免费观看 | 日日干夜夜骑 | 色播亚洲 | 中文在线免费视频 | 亚州1区2区3区4区产品乱码2021 | 日本一卡2卡3卡四卡精品 | 添人人躁日日躁夜夜躁夜夜揉 | 亚洲人成激情在线播放 | 日本卡一卡2卡3卡4精品卡无人区 | 日本高清在线播放一区二区三区 | 在线观看黄日本高清视频 | 青青视频免费观看 | 四虎精品免费永久在线 | 日本一区二区三区精品 | 涩涩屋导航 | 婷婷六| 微草影院 |