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

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

數據結構與算法(C#完成)系列---N叉樹(一)

[摘要]數據結構與算法(C#實現)系列---N叉樹(一)Heavenkiller(原創)N叉樹的每一節點度數都相同,為Nusing System;using System.Collections;namespace DataStructure /// <summary> ///...

數據結構與算法(C#實現)系列---N叉樹(一)

Heavenkiller(原創)

N叉樹的每一節點度數都相同,為N
using System;
using System.Collections;
namespace DataStructure

{

     /// <summary>

     /// NaryTree 的摘要說明。-----N叉樹

     /// </summary>

     public class NaryTree:Tree

     {

         // member variables

         protected object key;

         protected uint degree;

         protected ArrayList treeList=new ArrayList();

         //protected uint height=0;//暫時默認為0

 

         //create an empty tree whose attribute of degree is _degree

         public NaryTree(uint _degree)

         {

              //

              // TODO: 在此處添加構造函數邏輯

              //

              this.key=null;

              this.degree=_degree;

              this.treeList=null;

         }

         //構造一棵葉子結點的N叉樹

         public NaryTree(uint _degree,object _key)

         {

              this.key=_key;

              this.degree=_degree;

              this.treeList=new ArrayList();

              this.treeList.Capacity=(int)_degree;

 

              for(int i=0;i<this.treeList.Capacity;i++)

              {

                  

                   this.treeList.Add( this.GetEmptyInstance(_degree) );

              }

         }

         //-----------------------------------------------------------------

         protected virtual object GetEmptyInstance(uint _degree)

         {    return new NaryTree(_degree); }

         //-------------------------------------------------------------------

         //judge whether the tree is an empty tree

         public override bool IsEmpty()

         {    return this.key==null; }

         //判定是否是葉子結點。如果即不是空樹且每一棵子樹均為空樹,則為葉子結點

         public override bool IsLeaf()

         {

              if(IsEmpty())

                   return false;

              for(uint i=0;i<this.degree;i++)

              {

                   if(  !(this[i].IsEmpty()) )

                       return false;

              }

              return true;

         }

         //-----------------------------------Inherited Attributes---------------------------------

         public override object Key

         {

              get

              {

                   return this.key;

              }

         }

         //索引器

         public override Tree this[uint _index]

         {

              get

              {

                  

                   if( _index>=this.degree )

                       throw new Exception("My:out of index!");//如果出界,則拋出異常

                   if( this.IsEmpty() )

                       return null;//如果是空樹,則索引器返回一個 null

                   return (Tree)this.treeList[(int)_index];

              }

              set

              {

                   this.treeList[(int)_index]=value;

              }

         }




主站蜘蛛池模板: 亚洲精品午夜久久aaa级久久久 | 五月婷婷婷婷 | 全部免费毛片在线 | 天天亚洲 | 色花堂国产精品首页第一页 | 五月婷婷在线视频 | 中文字幕在线播放第一页 | 亚洲日本va中文字幕 | 青草视频在线观看视频 | 手机看片日韩国产一区二区 | 日韩一区精品视频在线看 | 亚洲剧场午夜在线观看 | 五月天丁香婷婷综合久久 | 天堂网2020 | 亚洲成在人线av | 图片区小说区欧洲区 | 欧美综合图区亚洲综合图区 | 四虎精品永久在线 | 亚洲成色www久久网站 | 日本特黄特色视频 | 午夜免费看 | 视频精品一区二区 | 自拍偷拍 欧美日韩 | 亚洲精品综合网 | 亚洲第一区二区快射影院 | 在线免费亚洲 | 手机在线观看mv网址 | 日本视频在线观看不卡高清免费 | 婷婷综合色伊人阁 | 亚洲欧美天堂综合久久 | 五月天丁香婷婷网 | 色天天天天 | 日韩 亚洲 中文 图片 小说 | 色一色在线观看视频网站 | 亚洲va国产va天堂va久久 | 天天干天天干天天干天天干 | 中文字幕一精品亚洲无线一区 | 伊人中文字幕在线观看 | 色影影院| 日韩毛片免费线上观看 | 亚洲精品自拍视频 |