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

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

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


主站蜘蛛池模板: 日日碰日日摸日日澡视频播放 | 性荡视频在线播放视频 | 亚洲 日本 欧美 中文字幕001 | 五月天婷婷色综合 | 天堂v| 日韩精品小视频 | 亚洲性久久 | 又大又爽又粗免费视频 | 欧美性色欧美a在线播放 | 日韩网站免费 | 日韩一区二区在线播放 | 日本免费人成在线网站 | 亚洲综合色就色手机在线观看 | 青娱乐自拍| 欧美一级视频免费 | 天天操天天摸天天曰天天干天天弄天天干 | 日本www色视频 | 四虎成人免费网址在线 | 日韩网站免费 | 日韩欧美在线综合网 | 亚欧成人一区二区 | 伊人手机视频 | 色站综合 | 伊人热人久久中文字幕 | 四虎影永久在线高清免费 | 日韩中文字幕在线视频 | 午夜影视在线视频观看免费 | 亚洲黄色一区 | 午夜色大片 | 日本欧洲亚洲一区在线观看 | 四虎国产欧美成人影院 | 亚洲综合区 | 在线看一区 | 伊人黄色片| 亚洲视频一区二区 | 一本视频在线 | 人人模人人看 | 一本久道久久综合 | 小小小小视频高清日本 | 天天拍天天射 | 天堂√在线官网 |