左儿子右兄弟表7K法
左儿子右兄弟表示法
树的左儿子右兄弟表示法又称为 二叉树表示法或二叉链表表示法。每个结点除了 data域外,还含有两个域,分别指向该结点的最左儿子和右邻兄弟。这种表示 法常用二叉链表实现,因此又称为 二叉链表表示法。但是实际应用中常用游标 (静态链表)来代替链表,请参见表的游标实现。
若用指针实现,其类型定义为:
Type
TPositi on=ANodeType;
NodeType=record
Label:LabelType;
Leftmost_Child,Right_Sibli ng:TPositio n; en d;
TreeType=TPositi on;
若用游标实现,其类型定义为
Type
TPositi on=in teger;
NodeType=record
Label:LabelType;
Leftmost_Child,Right_Sibli ng:TPositio n; en d;
CellspaceType=array [1..MaxNodeCou nt] of NodeType;
TreeType=TPositi on;
var
Cellspace:CellspaceType;
Tree:TreeType;
此时树类型TreeType是整数类型,它指示树根在 cellspace中的游标。例如图 5(a)中树的左儿子右兄弟表示法的指针和
原创力文档

文档评论(0)