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

明輝手游網(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();
           }


主站蜘蛛池模板: 最近最中文字幕视频 | 午夜激情视频 | 婷婷开心中文字幕 | 一级爱爱片| 亚洲 欧美 日韩中文字幕一区二区 | 日本乱人伦片中文字幕三区 | 亚洲综合图色40p | 亚洲国产99在线精品一区69堂 | 亚洲免费在线看 | 青娱乐免费视频 | 亚洲影视精品 | 亚洲福利视频网站 | 天天拍天天干 | 亚洲欧洲在线视频 | 色碰视频 | 色黄视频 | 在线a网站 | 色在线网站免费观看 | 日韩 欧美 综合 | 欧美一区二区三区精品国产 | 字幕网资源站中文字幕 | 日韩资源 | 伊人三级 | 欧美一级成人一区二区三区 | 色噜噜噜噜噜噜 | 亚洲三级欧美 | 日本一区二区三区欧美在线观看 | 日本不卡一区二区三区 | 欧洲毛片 | 四虎精品免费永久在线 | 四虎影院最新地址 | 欧美又粗又硬 | 亚洲免费在线视频观看 | 小黄鸭b站视频在线 | 日韩免费a级在线观看 | 婷婷丁香五月中文字幕 | 天天综合网天天综合色 | 日韩一区二紧身裤 | 日韩黄色一级毛片 | 手机在线观看亚洲国产精品 | 日本高清免费一本视频无需下载 |