树形结构

 

双亲表示法

Public Const MaxSize As Integer = 10

 

Public Type pnode

info As String

parent As Integer

End Type

 

Public Type ptree

data(0 To MaxSize – 1) As pnode

num As Integer ‘树当前中的节点数目

End Type

 

Private Sub CommandButton1_Click()

Dim tree As ptree

tree.num = 8

tree.data(0).info = “a”

tree.data(0).parent = -1

tree.data(1).info = “b”

tree.data(1).parent = 0

tree.data(2).info = “c”

tree.data(2).parent = 0

tree.data(3).info = “d”

tree.data(3).parent = 0

tree.data(4).info = “e”

tree.data(4).parent = 1

tree.data(5).info = “f”

tree.data(5).parent = 1

tree.data(6).info = “g”

tree.data(6).parent = 3

tree.data(7).info = “h”

tree.data(7).parent = 4

End Sub

 

孩子表示法

 

双亲孩子表示法

 

孩子兄弟表示法