熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

數據結構與算法

2022-06-13   來源: .NET編程 

  廣義樹和基本樹的主要區別就是有任意的度

  usingSystem;

  usingSystemCollections;

  namespaceDataStructure{

  ///<summary>

  ///GeneralTree的摘要說明

  ///generaltreeisatreewhichhasaarbitrarydegreeandnoemptytree

  ///useArrayListtoreplaceListAsLinkedList

  ///</summary>

  publicclassGeneralTree:Tree  {

  protectedobjectkey=null;    protecteduintdegree=;

  //protecteduintheight=;

  protectedArrayListtreeList=newArrayList();

  publicGeneralTree(object_objKey)    {

  //

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

  //

  key=_objKey;

  degree=;

  //

  height=;

  ArrayListtreeList=newArrayList();

  }

  publicvirtualvoidAttackSubtree(GeneralTree_gTree)    {

  thistreeListAdd(_gTree);

  ++degree;

  }

  publicvirtualGeneralTreeDetachSubtree(GeneralTree_gTree)    {

  thistreeListRemove(_gTree);

  degree;

  return_gTree;

  //????? howtoremovereferenceorobject????

  }

  publicoverrideTreethis[uint_index]

  {

  get

  {

  if(_index>=thisdegree)

  thrownewException(my:outofindex);

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

  }

  set

  {

  treeList[(int)_index]=value;

  }

  }


From:http://tw.wingwit.com/Article/program/net/201311/13543.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.