高级数据结构与算法习题(2)

一、判断题

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。插入过程如下:

  • 20
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

博学者普克尔特

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值