文档介绍:怎么用vb建立二叉树,?悬赏分:100-解决时间:2006-8-616:55最好能给出程序,谢谢问题补充:不要用网上搜的C语言程序糊弄我==+Treeview控件VB自带的么?提问者:yedi9-见习魔法师三级最佳答案'二叉树的结点类OptionExplicitPrivatemNodeValueAsString'结点值PrivatemLeftNodeAsclsBiTreeNode'左结点PrivatemRightNodeAsclsBiTreeNode'右结点'得到结点的值PublicPropertyGetNodeValue()AsStringNodeValue=mNodeValueEndProperty'设置结点的值PublicPropertyLetNodeValue(ByValpNodeValueAsString)mNodeValue=pNodeValueEndProperty'得到左结点PublicPropertyGetLeftNode()AsclsBiTreeNodeSetLeftNode=mLeftNodeEndProperty'设置左结点PublicPropertyLetLeftNode(ByValpLeftNodeAsclsBiTreeNode)SetmLeftNode=pLeftNodeEndProperty'得到右结点PublicPropertyGetRightNode()AsclsBiTreeNodeSetRightNode=mRightNodeEndProperty'设置右结点PublicPropertyLetRightNode(ByValpRightNodeAsclsBiTreeNode)SetmRightNode=pRightNodeEndProperty-----------------------'一个二叉树的类OptionExplicitPrivatemRootAsclsBiTreeNode'建立一棵二叉树,同时以strValue为值建立根结点PublicSubCreateTree(strValueAsString)SetmRoot==strValueEndSub'求二叉树的根结点PublicFunctionRoot()AsclsBiTreeNodeSetRoot=mRootEndFunction'求二叉树中值为strValue的结点的双亲PublicFunctionParent(strValueAsString)AsclsBiTreeNodeDimNodeTempAsclsBiTreeNodeFindNodemRoot,strValue,NodeTempSetParent=NodeTempEndFunction'求二叉树T中值为strValue的结点的左孩子PublicFunctionLeftChild(strValueAsString)AsclsBiTreeNodeDimNodeTempAsclsBiTreeNodeSetLeftChild=NothingSetNodeTemp=FindNode(mRoot,strValue)IfNotNodeTempIsNothingThenSetLeftChild='求二叉树T中值为strValue的结点的右孩子PublicFunctionRightChild(strValueAsString)AsclsBiTreeNodeDimNodeTempAsclsBiTreeNodeSetRightChild=NothingSetNodeTemp=FindNode(mRoot,strValue)IfNotNodeTempIsNothingThenSetRightChild='遍历二叉树:采用前序遍历*******************PublicSubTraverseF(ByRefNodeAsclsBiTreeNode)&":"'遍历二叉树:采用中序遍历*****************PublicSubTraverseM(ByRefNodeAsclsBiTreeNode)&":"