[题集]Lecture2.Red-Black Trees and B+ Trees

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的底数,因此差一个常数倍

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值