数据结构与算法(C#实现)系列---广义树(一)
数据结构与算法(C#实现)系列---广义树(一)
Heavenkiller(原创)
广义树和基本树的主要区别就是有任意的度
using System;
using System.Collections;
namespace DataStructure
{
/// <summary>
/// GeneralTree 的摘要说明。
/// general tree is a tree which has a arbitrary degree and no empty tree
/// use ArrayList to replace ListAsLinkedList
/// </summary>
public class GeneralTree:Tree
{
protected object key=null;
protected uint degree=0;
//protected uint height=0;
protected ArrayList treeList=new ArrayList();
public GeneralTree(object _objKey)
{
//
// TODO: 在此处添加构造函数逻辑
//
key=_objKey;
degree=0;
// height=0;
ArrayList treeList=new ArrayList();
}
public virtual void AttackSubtree(GeneralTree _gTree)
{
this.treeList.Add(_gTree);
++degree;
}
public virtual GeneralTree DetachSubtree(GeneralTree _gTree)
{
this.treeList.Remove(_gTree);
degree--;
return _gTree;//????? how to remove ,reference or object????
}
public override Tree this[uint _index]
{
get
{
if(_index>=this.degree)
throw new Exception("my:out of index");
return (Tree)treeList[(int)_index];
}
set
{
treeList[(int)_index]=value;
}
}
- 如果您发现链接错误,请通知我们,不胜感激。
- 如果您认为本站文章侵犯您的版权,请通知我们,我们将立即删除。
- 本站提供的文章收集连接于其他网站,版权归作者所有。
- 本站的文章仅供学习和研究之用,严禁用于商业用途。
- 文章中心总数:51611篇
- 今日更新文章:0篇
- 本周更新文章:0篇
- 备用更新文章:10篇

