我在外国学习,无意选修了这个科目。
现在快考试了,复习题,没有答案。但很重要。
我把题目列在这里。英文原文有,中文我也写上了。 五个内容先问前3个,是一起的。能不能帮我看看先。 我研究了好久,查了很多资料,不过都无法应用在这题目上。。
汗。。 第一题就是求 height,第二题是 删除一个节点,第三题是 写个main的语句,print出 height和删除节点后的数字列。 1
The height of a node v in binary tree T is defined as the number of descendants on the longest path from v to a leaf node. Add one method, called Height, to BinarySearchTree.java for evaluating the height of a node.
在BinarySearchTree.java里增加一个method Height,计算一个node的高度。 2
Add another method, called Remove, to BinarySearchTree.java. By using this method, a node in a binary search tree can be removed. The implementation must follow the algorithm for deletion of a node from a binary search tree
在BinarySearchTree.java里增加一个method Remove,用这个method删除一个二叉搜索树的节点。这项工具一定要遵循二叉搜索树的节点删除算法。 3
Write a test program that verifies your implementation of the two methods above.
写一个测试程序来检测上面两个method是否可执行。
4
Write a program that (i) read in a sequence of surnames from the standard input (or terminal); (ii) insert them into a binary search tree where the names are used as keys; (iii) print them as the results of pre-order, post-order and in-order traversals.
写一个程序 1、从标准输入或终端,按照顺序来读取“姓”。2、把他们插进一个二叉搜索树,并且姓名是用作key的。3、分别按先序遍历、后序、中序遍历法print这些结果。 5
Write a program that implements iterative post-order traversal for a binary tree by using a stack. In addition, The test program must be provided.
写一个程序,用 stack栈 来执行一个二叉树的反复后序遍历法。另外,这个测试程序也必须提供出来。
谢谢哈~~时间不多了~~附件在
http://javajerry.ys168.com/
谢谢
现在快考试了,复习题,没有答案。但很重要。
我把题目列在这里。英文原文有,中文我也写上了。 五个内容先问前3个,是一起的。能不能帮我看看先。 我研究了好久,查了很多资料,不过都无法应用在这题目上。。
汗。。 第一题就是求 height,第二题是 删除一个节点,第三题是 写个main的语句,print出 height和删除节点后的数字列。 1
The height of a node v in binary tree T is defined as the number of descendants on the longest path from v to a leaf node. Add one method, called Height, to BinarySearchTree.java for evaluating the height of a node.
在BinarySearchTree.java里增加一个method Height,计算一个node的高度。 2
Add another method, called Remove, to BinarySearchTree.java. By using this method, a node in a binary search tree can be removed. The implementation must follow the algorithm for deletion of a node from a binary search tree
在BinarySearchTree.java里增加一个method Remove,用这个method删除一个二叉搜索树的节点。这项工具一定要遵循二叉搜索树的节点删除算法。 3
Write a test program that verifies your implementation of the two methods above.
写一个测试程序来检测上面两个method是否可执行。
4
Write a program that (i) read in a sequence of surnames from the standard input (or terminal); (ii) insert them into a binary search tree where the names are used as keys; (iii) print them as the results of pre-order, post-order and in-order traversals.
写一个程序 1、从标准输入或终端,按照顺序来读取“姓”。2、把他们插进一个二叉搜索树,并且姓名是用作key的。3、分别按先序遍历、后序、中序遍历法print这些结果。 5
Write a program that implements iterative post-order traversal for a binary tree by using a stack. In addition, The test program must be provided.
写一个程序,用 stack栈 来执行一个二叉树的反复后序遍历法。另外,这个测试程序也必须提供出来。
谢谢哈~~时间不多了~~附件在
http://javajerry.ys168.com/
谢谢
楼主【suifp】截止到2008-07-08 22:08:59的历史汇总数据(不包括此帖):
发帖的总数量:0 发帖的总分数:0 每贴平均分数:0
回帖的总数量:0 得分贴总数量:0 回帖的得分率:0%
结贴的总数量:0 结贴的总分数:0
无满意结贴数:0 无满意结贴分:0
未结的帖子数:0 未结的总分数:0
结贴的百分比:---------------------结分的百分比:---------------------
无满意结贴率:---------------------无满意结分率:---------------------
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
在BinarySearchTree.java里增加一个method Height,计算一个node的高度。 这个问题首先要清楚最上面一层高为1还是0,各有各说法,算法导论一书中最顶层高为0。
那么有n个node的二叉树,高度为不大于log2n(以2为底n的对数)的整数。