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

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

數據結構與算法(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();
           }


主站蜘蛛池模板: 欧美影院一区二区三区 | 青青草原国产在线视频 | 午夜美女视频在线观看高清 | 欧美特黄特色aaa大片免费看 | 天天色天天色 | 日韩在线视| 日本一区欧美 | 欧洲免费极品videos | 亚洲欧美综合一区 | 影音先锋色图 | 四虎影院免费视频 | 色日韩在线 | 欧美在线视频免费观看 | 亚洲人成综合在线播放 | 天天干天天干天天干 | 日本www色视频成人免费 | 亚洲视频在线观看一区 | 亚洲福利二区 | 日本黄 色 成 年 人免费观看 | 日韩精品成人 | 日本中文一二区有码在线观看 | 日日噜噜夜夜躁躁狠狠 | 青娱乐精品视频在线观看 | 特级片在线观看 | 亚洲国产天堂久久综合 | 日韩免费一级 | 亚洲免费网站 | 深夜福利影院在线观看 | 日韩人成免费网站大片 | 日日摸人人看97人人澡 | 性大交 | 热思思久久 | 青青青草视频在线观看 | 亚洲最大成人网色 | 中文国产成人精品久久一 | 亚洲国产一区在线观看 | 青青国产视频 | 亚洲成a人片77777老司机 | 青青草影院在线观看 | 欧美视频手机在线 | 亚洲欧美伦理 |