數據結構與算法(周測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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM