1.A 2-3 tree with 3 nonleaf nodes must have 18 keys at most.
一个叶子节点最多放3个值,然后是两个节点指向3个叶子,然后是一个根指向两个节点。
那么一共有2*3个叶子,一个叶子存放3个key,一共18个.注意key只算叶子上的。T
2.In the red-black tree that results after successively inserting the keys 41; 38; 31; 12; 19; 8 into an initially empty red-black tree, which one of the following statements is FALSE?
A.38 is the root
B.19 and 41 are siblings, and they are both red
C.12 and 31 are siblings, and they are both black
D.8 is red
插入当作红,如果出现红红:以最下方的红节点来看,如果父兄同是红色,直接爷爷变红,父兄变黑。
不是,则首先转为RR或者LL,然后转一下,让最上面一个节点变黑,两个孩子变红。
一开始,插入31是第2种,插入12是第1种,插入19是转一下第2种
B
3.After deleting 15 from the red-black tree given in the figure, which one of the following statements must be FALSE?
A.11 is the parent of 17, and 11 is black
B.17 is the parent of 11, and 11 is red
C.11 is the parent of 17, and 11 is red
D.17 is the parent of 11, and 17 is black
如果拿11顶,则11是红肯定不行
如果拿17顶,则17是红肯定不行,选C
4.Insert 3, 1, 4, 5, 9, 2, 6, 8, 7, 0 into an initially empty 2-3 tree (with splitting). Which one of the following statements is FALSE?
A.7 and 8 are in the same node
B.the parent of the node containing 5 has 3 children
C.the first key stored in the root is 6
D.there are 5 leaf nodes
A
结果是:叶子:0 1,2 3,4 5,6 7,8 9
上一层:2 4,8
根:6
5.After deleting 9 from the 2-3 tree given in the figure, which one of the following statements is FALSE?
A.the root is full
B.the second key stored in the root is 6
C.6 and 8 are in the same node
D.6 and 5 are in the same node
删除这个指针,删除这个值,放在相邻的节点中。
如果是非叶子节点,从父节点拿下一个来。
D
6.Which of the following statements concerning a B+ tree of order M is TRUE?
A.the root always has between 2 and M children
B.not all leaves are at the same depth
C.leaves and nonleaf nodes have some key values in common
D.all nonleaf nodes have between ⌈M/2⌉ and M children
A:当root是叶子时,错。0个孩子
B:错,C:对,某些key是相同的。D:(M-1)/2 to M-1 个key, M/2到M个children, 但是根可以只有两个。
7.In a Red-Black tree, the path from the root to the farthest leaf is no more than twice as long as the path from the root to the nearest leaf.
T, far=R+B, near=B, R+B<= 2B => R<= B. 红节点个数小于黑节点个数,正确。
8.The root of a B+ tree of order m has at most m subtrees.
m个指针,最多了。T
9.In a red-black tree with 2 nodes, there must be a red node
T。如果两个黑的,那么上面那个就不对了。
10.In a red-black tree with 3 nodes, there must be a red node.
F,3个黑的是可以的。
11.When inserting a node into a red-black tree, we shall first insert the node as into an ordinary binary search tree, and then color the node black.
F,应该是red
12.The following binary search tree is a valid red-black tree
红节点不能单连一个黑节点,因为红节点到NULL的黑节点是0个,到另一个NULL的黑节点是1个
13.The time bound of the FIND operation in a B+ tree containing N numbers is O(logN), no matter what the degree of the tree is.
T 不同的在于log的底数,因此差一个常数倍