赞
踩
前言:最近快到FDS考试了,po重刷了一下学校的题目,自己整理了一些解析orz 因为po在自己找解析和学习的过程中非常痛苦,所以在此共享一下我的题目和自己写的解题思路,欢迎各位指出错误~全章节预计会陆续更新,可在专栏查看~
HW4
1.It is always possible to represent a tree by a one-dimensional integer array.
T 用一维整数数组,顺序表示是可以的;或者用链表表示
2.There exists a binary tree with 2016 nodes in total, and with 16 nodes having only one child.
F 用n0+n1+n2 = 2016, n0 = n2 +1 代入,发现除不尽
3.Given a tree of degree 3. Suppose that there are 3 nodes of degree 2 and 2 nodes of degree 3. Then the number of leaf nodes must be ____.
8;度为3的树,画图即可。
4.If a general tree T is converted into a binary tree BT, then which of the following BT traversal
s gives the same sequence as that of the post-order traversal of T?
中序遍历 In order 画一遍树即可判断。普通树变成二叉树的方法是:保留长子,把后续的兄弟结点都变成长子的孩子;然后把树旋转45度即可。
5. Given the shape of a binary tree shown by the figure below. If its inorder traversal sequence is { E, A, D, B, F, H, C, G }, then the node on the same level of C must be:
E 画图即可 inorder满足左-根-右;首先根据这棵树左4右3,可以判断root为F,EADB在左子树,FHCG在右子树。后续几层也可以根据左右子树元素个数进行推断,得树:F; EC; DHG, AB(层序遍历顺序,按照逗号分割每层)
6.Among the following threaded binary trees (the threads are represented by dotted curves), which one is the postorder threaded tree?
B 要注意threaded binary tree的性质,没有子树时才能指向
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。