• 数据结构与算法(周测2-AVL树)


    判断题

    1.The inorder traversal sequence of an AVL tree must be in sorted (non-decreasing) order.

         T      F
    根据二叉搜索树性质,中序遍历一定是有序的,而且是递增的。

    2.Insert 1, 2, 3, 4, 5, and 6 one by one into an initially empty AVL tree. Then the preorder traversal sequence of the resulting tree must be {4, 2, 1, 3, 5, 6}.

         T      F
    最终的AVL树: ![](https://img2018.cnblogs.com/blog/1694164/201911/1694164-20191105185618938-221135412.png)

    3.For any node in an AVL tree, the height of the left subtree must be greater than that of the right subtree.

         T      F

    4.For an AVL tree, the balance factors of all the non-leaf nodes are 0 iff the tree is a complete binary tree.

         T      F
    只有完美二叉树满足这个定义。

    5.If the depth of an AVL tree with nodes { 1, 2, 3, 4 } is 3 (the depth of the root is 1), then either node 2 or node 3 must have two children.

         T      F
    ![](https://img2018.cnblogs.com/blog/1694164/201911/1694164-20191105154342973-67853767.png) ![](https://img2018.cnblogs.com/blog/1694164/201911/1694164-20191105155115749-509284968.png)

    6.任何AVL树的中序遍历结果是有序的(从小到大)。

         T      F

    7.将1、2、3、4、5、6顺序插入初始为空的AVL树中,当完成这6个元素的插入后,该AVL树的先序遍历结果是:4、2、1、3、5、6。

         T      F
    见第二题。

    8.For any node in an AVL tree, the height of the right subtree must be greater than that of the left subtree.

         T      F

    9.对AVL树中的任一结点,其左子树的高度一定比其右子树的高度要高。

         T      F

    10.An AVL tree with the balance factors of all the non-leaf nodes being 0 must be a perfect binary tree.

         T      F
    所有的非叶结点的平衡因子都是0,意味着左右子树的高度都相同,只有当树是完美二叉树的时候才满足。

    11.对一棵平衡二叉树,所有非叶结点的平衡因子都是0,当且仅当该树是完全二叉树。

         T      F
    应该是完美二叉树,完全二叉树最后一层结点不一定要满,这样父结点中肯定会有平衡因子不为0的结点。

    12.若一棵平衡二叉树的所有非叶结点的平衡因子都是0,则其必为完美二叉树。

         T      F
    同第10题

    13.If the depth of an AVL tree with nodes { 1, 2, 3, 4 } is 3 (the depth of the root is 1), then it is possible for node 4 to be the root.

         T      F
    如果4是根结点,右子树上肯定没有元素,即使左子树上深度只能为1,而结点有3个,不可能。

    14.如果由结点{ 1, 2, 3, 4 }组成的AVL树的深度是3(根结点的深度是1),则结点2或者结点3一定有两个子结点。

         T      F
    同第5题。

    15.如果由结点{ 1, 2, 3, 4 }组成的AVL树的深度是3(根结点的深度是1),则结点4有可能是根结点。

         T      F
    同第13题。

    选择题

    1.Which of the following is TRUE for any node in an AVL tree?

        A.The left and right subtrees have the same height
        B.The absolute value of the difference between the heights of left and right subtrees is no more than 1
        C.The height of the left subtree is always greater than that of the right subtree
        D.The height of the left subtree is always less than that of the right subtree

    2.Insert key 48 into the balanced binary tree shown by the figure. Then in the resulting balanced tree, the left- and right-child of key 37 are:
    img

        A.13 and 48
        B.24 and 48
        C.24 and 53
        D.24 and 90
    插入后的树: ![](https://img2018.cnblogs.com/blog/1694164/201911/1694164-20191105180721722-692766969.png)

    3.Insert 2, 1, 4, 5, 9, 3, 6, 7 into an initially empty AVL tree. Which one of the following statements is FALSE?

        A.4 is the root
        B.3 and 7 are siblings
        C.2 and 6 are siblings
        D.9 is the parent of 7
    插入后的树: ![](https://img2018.cnblogs.com/blog/1694164/201911/1694164-20191105181841403-750524070.png)

    4.If the depth of an AVL tree is 5 (the depth of an empty tree is defined to be ?1), then the minimum possible number of nodes in this tree is:

        A.12
        B.20
        C.33
        D.64
    根据递推公式F(N)=F(N-1)+F(N-2)+1,得到序列F(1)=1,F(2)=2,F(3)=4,F(4)=7,F(5)=12,F(6)=20。

    5.Insert { 9, 8, 7, 2, 3, 5, 6, 4} into an initially empty AVL tree. Which one of the following statements is FALSE?

        A.5 is the root
        B.2 and 5 are siblings
        C.there are 2 nodes with their balance factors being -1
        D.the height of the resulting AVL tree is 3
    插入后的树: ![](https://img2018.cnblogs.com/blog/1694164/201911/1694164-20191105184810504-1917428546.png)

    6.After inserting 28, 22, and 35 into the given AVL tree, the children of node 25 are __。
    img

        A.22 and 28
        B.20 and 28
        C.22 and 30
        D.20 and 30
    插入后的树: ![](https://img2018.cnblogs.com/blog/1694164/201911/1694164-20191105185339389-728733754.png)

    7.下列二叉搜索树中,满足平衡二叉树定义的是:

        A.
        B.
        C.
        D.
    其他几个平衡因子太大了

    8.在下列所示的平衡二叉树中,插入关键字48后得到一棵新平衡二叉树。在新平衡二叉树中,关键字37所在结点的左、右子结点中保存的关键字分别是:
    img

        A.13、48
        B.24、48
        C.24、53
        D.24、90
    同第2题

    9.12个结点的AVL树的最大深度是?

        A.3
        B.4
        C.5
        D.6
    类似第4题,但与第4题不同的是,一般认为空树深度是0,所以选5。

    10.若AVL树的深度是6(空树的深度定义为-1),则该树的最少结点数是:

        A.13
        B.17
        C.20
        D.33
    类似第4题。

    11.Among the following trees, which one satisfies the definition of a balanced tree?

        A.
        B.
        C.
        D.
    同第7题

    12.The maximum possible depth of an AVL tree with 12 nodes is:

        A.3
        B.4
        C.5
        D.6
    同第9题

    13.Insert {88, 70, 61, 96, 120, 90} one by one into an initially empty AVL tree. Then the preorder traversal sequence of the resulting AVL tree is:

        A.61,70,88,90,96,120
        B.90,70,61,88,96,120
        C.88,70,61,90,96,120
        D.88,70,61,96,90,120
    插入后的树: ![](https://img2018.cnblogs.com/blog/1694164/201911/1694164-20191105222120984-1025092697.png)

    14.If the depth of an AVL tree is 6 (the depth of an empty tree is defined to be -1), then the minimum possible number of nodes in this tree is:

        A.13
        B.17
        C.20
        D.33
    同第14题

    15.将 2, 1, 4, 5, 9, 3, 6, 7 顺序插入一棵初始为空的AVL树。下列句子中哪句是错的?

        A.4 是根结点
        B.3 和 7 是兄弟
        C.2 和 6 是兄弟
        D.9 是 7 的父结点
    同第3题

    16.如果AVL树的深度为5(空树的深度定义为-1),则此树最少有多少个结点?

        A.12
        B.20
        C.33
        D.64
    同第4题

    17.如果AVL树的深度为6(空树的深度定义为-1),则此树最少有多少个结点?

        A.12
        B.20
        C.33
        D.64
    类似第4题

    18.将一系列数字顺序一个个插入一棵初始为空的AVL树。下面哪个系列的第一次旋转是"右-左"双旋?

        A.1,2,3,4,5,6
        B.6,5,4,3,2,1
        C.4,2,5,6,3,1
        D.3,1,4,6,5,2
    A、B选项都是单旋转,C选项不用旋转

    19.将 1, 2, 3, 6, 5, 4 顺序一个个插入一棵初始为空的AVL树,会经历下列哪些旋转?

        A.两个"右-右"旋和一个"右-左"旋
        B.一个"右-右"旋、一个"右-左"旋、一个"左-右"旋
        C.一个"右-右"旋和两个"右-左"旋
        D.两个"右-右"旋和一个"左-右"旋
    当插入3的时候,结点全在右子树上,执行一次"右-右"旋;当插入5的时候,3、6、5需要执行一次"右-左"旋;当插入4时,2,5,6需要执行一次"右-左"旋

    20.在任意一棵非空平衡二叉树(AVL 树)T1 中,删除某结点 v 之后形成平衡二叉树 T2,再将 v 插入 T2 形成平衡二叉树 T3。下列关于 T1 与 T3 的叙述中,正确的是:

    • I、若 v 是 T1 的叶结点,则 T1 与 T3 可能不相同
    • II、若 v 不是 T1 的叶结点,则 T1 与 T3 一定不同
    • III、若 v 不是 T1 的叶结点,则 T1 与 T3 一定相同
        A.仅 I
        B.仅 II
        C.仅 I、II
        D.仅 I、III
  • 相关阅读:
    c语言----- 冒泡排序 for while do-while 递归练习
    c语言----实战植物大战僵尸
    c语言-----劫持系统03
    c语言-----劫持自己02
    c语言-----劫持原理01
    win10神州网信政府版去掉屏保
    将WebApi发布到IIS上(IIS6.0)(转)
    关于Logstash中grok插件的正则表达式例子
    说说看板在项目中的应用
    解决Gradle报错找不到org.gradle.api.internal.project.ProjectInternal.getPluginManager()方法问题
  • 原文地址:https://www.cnblogs.com/nonlinearthink/p/11770770.html
Copyright © 2020-2023  润新知