文件名称:ccc
介绍说明--下载内容均来自于网络,请自行研究使用
在二叉搜索树上删除一个有两个子女的结点时,可以采用以下三种方法:
(1) 用左子树TL上具有最大关键码的结点X顶替,再递归地删除X。
(2) 交替地用左子树TL上具有最大关键码的结点和右子树TR上具有最小关键码的结点顶替,再递归地删除适当的结点。
(3) 用左子树TL上具有最大关键码的结点或者用右子树TR上具有最小关键码的结点顶替,再递归地删除适当的结点。可随机选择其中一个方案。
试编写程序实现这三个删除方法,并用实例说明哪一个方法最易于达到平衡化。
-In the binary search tree delete a node with two children, you can use the following three ways: (1) with a left subtree TL key code with the largest node X replacement, and then recursively delete X. (2) alternately with the left subtree TL key code with the largest node, and the right subtree TR on the key code with minimal replacement of nodes, then recursively delete the appropriate node. (3) with a left subtree TL key code with the largest node or with the right subtree TR key code that has the smallest node replacement, recursively delete the appropriate node. Can randomly select one of the options. Try to delete programming to achieve these three methods, with examples which the balance of the easiest ways.
(1) 用左子树TL上具有最大关键码的结点X顶替,再递归地删除X。
(2) 交替地用左子树TL上具有最大关键码的结点和右子树TR上具有最小关键码的结点顶替,再递归地删除适当的结点。
(3) 用左子树TL上具有最大关键码的结点或者用右子树TR上具有最小关键码的结点顶替,再递归地删除适当的结点。可随机选择其中一个方案。
试编写程序实现这三个删除方法,并用实例说明哪一个方法最易于达到平衡化。
-In the binary search tree delete a node with two children, you can use the following three ways: (1) with a left subtree TL key code with the largest node X replacement, and then recursively delete X. (2) alternately with the left subtree TL key code with the largest node, and the right subtree TR on the key code with minimal replacement of nodes, then recursively delete the appropriate node. (3) with a left subtree TL key code with the largest node or with the right subtree TR key code that has the smallest node replacement, recursively delete the appropriate node. Can randomly select one of the options. Try to delete programming to achieve these three methods, with examples which the balance of the easiest ways.
(系统自动生成,下载前可以参看下载内容)
下载文件列表
ccc.doc