数据结构英文习题解析-第五章 二叉搜索树Binary Search Tree

本文分享了关于二叉搜索树的习题,包括排序规则、层次关系、插入顺序、删除影响、预后序遍历及决策树构建。通过实例解析了关键概念并讨论了可能的错误理解。
摘要由CSDN通过智能技术生成

前言:最近快到FDS考试了,po重刷了一下学校的题目,自己整理了一些解析orz 因为po在自己找解析和学习的过程中非常痛苦,所以在此共享一下我的题目和自己写的解题思路,欢迎各位指出错误~全章节预计会陆续更新,可在专栏查看~

HW5

1.In a binary search tree, the keys on the same level from left to right must be in sorted (non-decreasing) order.

T

2.In a binary search tree which contains several integer keys including 4, 5, and 6, if 4 and 6 are on the same level, then 5 must be their parent.

F;4和6可能不是同一个parent的两个child,可能4是rchild,6是lchild

3. Given a binary search tree as shown in the following figure. Which of the following relationships is correct with respect to the given tree?

1<3<5<4<2;遵循左子树小,右子树大的原则

4.Given the structure of a binary search tree (as shown in the figure), which one of the following insertion sequences is impossible? 

A.83 67 91 98 20 75

B.83 67 75 91 20 98

C.83 91 75 67 20 98 

D.83 91 98 67 75 20

C;按顺序画图即可

5.Given a binary search tree with its preorder traversal sequence { 8, 2, 15, 10, 12, 21 }. If 8 is deleted from the tree, which one of the following statements is FALSE? 

A.One possible preorder traversal sequence of the resulting tree may be { 2, 15, 10, 12, 21 }

B.One possible preorder traversal sequence of the resulting tree may be { 10, 2, 15, 12, 21 }

C.One possible preorder traversal sequence of the resulting tree may be { 15, 10, 2, 12, 21 }

D.It is possible that the new root may have 2 children

C;删除搜索二叉树,需要用中序遍历的前驱或后继替代根节点,对应AB两种情况

6.Insert {5, 2, 7, 3, 4, 1, 6} one by one into an initially empty binary search tree. The postorder traversal sequence of the resulting tree is: 

A.1, 2, 3, 4, 6, 7, 5

B.1, 4, 2, 6, 3, 7, 5

C.1, 4, 3, 2, 6, 7, 5

D.5, 4, 3, 7, 6, 2, 1

C;注意问的是后序遍历结果

7.Among the following binary trees, which one can possibly be the decision tree (the external nodes are excluded) for binary search?

A 这道题目我看了好久,可以通过根节点左右子树大小判断mid取大还是取小,比如A选项这张图左子树5个节点右子树4个节点,那mid是(left+right)/2+1(取大);同时叶结点只会往同一侧偏(因为取大还是取小整棵树应该统一)

8. For a binary search tree, in which order of traversal that we can obtain a non-decreasing sequence? 

A.preorder traversal

B.postorder traversal

C.inorder traversal

D.level-order traversal

C;中序顺序得到的就是按顺序排列结果。

  • 36
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值