一、判断题
A 2-3 tree with 3 nonleaf nodes must have 18 keys at most.
T F
解析:T。2-3 的B+tree意味着非根节点有2个或者3个元素。而这个B+树有3个非叶子节点,可知为根节点下面两个非叶子节点组成,而为了使他keys最多,则这两个下面都各接3个叶子节点,每片叶子里面存储3个元素,故一共有2*3*3=18个keys。
二、单选题
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
解析:B。插入过程如下:
我们可以发现19是红色而41是黑色,故B错误。
2、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
解析:C。无论是用11还是用17替换了15的位置,都必不能是红色的(否则黑高错误,不满足第5条:从任一节点到每个叶子的所有路径都包含数目相同的黑色节点这一性质),只能顶上去的那个节点是黑色而下面不动的那个节点变成红色。故C错误。
3、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。插入过程如下: