1 / 11
文档名称:

怎么用vb建立二叉树.doc

格式:doc   大小:24KB   页数:11
下载后只包含 1 个 DOC 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

怎么用vb建立二叉树.doc

上传人:文库旗舰店 2019/10/3 文件大小:24 KB

下载得到文件列表

怎么用vb建立二叉树.doc

文档介绍

文档介绍:怎么用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)&":"