هياكل البيانات والخوارزميات (DSA27) · الأسبوع 11

Trees (Lecture 11)

هذه اختبارات للتدريب الذاتي، تُحفظ إجاباتك على هذا الجهاز فقط ولا تُرسل إلى أحد. الأسئلة والشرح بالإنجليزية لغة المقرر.

النتيجة: 0 / 22 · أُجيب: 0

  1. W11-M01 تذكّر

    A leaf is a node that:

  2. W11-M02 تذكّر

    With height counted in edges, the height of a tree with exactly one node is:

  3. W11-M03 تطبيق

    The largest number of nodes a binary tree of height 3 can hold is:

  4. W11-M04 تطبيق

    The smallest possible height of a binary tree with 100 nodes is:

  5. W11-M05 تذكّر

    A binary tree is a binary search tree when, for every node x:

  6. W11-M06 تطبيق

    In the tree Q, the right child of the root's left child is:

  7. W11-M07 تطبيق

    contains(25) on Q compares 25 with how many nodes?

  8. W11-M08 تعليل

    The worst-case cost of contains on a BST of n nodes, built by dsa/tree.py from values in an unknown order, is:

  9. W11-M09 تطبيق

    Which insertion order of 1 to 7 builds the tallest BST?

  10. W11-M10 تطبيق

    The pre-order walk of Q is:

  11. W11-M11 تطبيق

    The post-order walk of Q is:

  12. W11-M12 تذكّر

    Which walk of any BST lists its values in increasing order?

  13. W11-M13 تعليل

    You save a BST to a file as a list of values, and later rebuild it by inserting the list into an empty tree. To get back the same shape, the list should be the tree's:

  14. W11-M14 تعليل

    Which walk frees a tree safely in a language where you release memory yourself, and evaluates an expression tree?

  15. W11-M15 تعليل

    level_order uses a queue rather than the call stack because:

  16. W11-M16 تطبيق

    During level_order on Q, the largest number of nodes waiting in the queue at one time is:

  17. W11-M17 تذكّر

    Deleting a node with two children, dsa/tree.py replaces its value with:

  18. W11-M18 تطبيق

    delete(30) on Q. Which value ends up at the root?

  19. W11-M19 تعليل

    The in-order successor of a node with two children never has a left child. Why does that matter to delete?

  20. W11-M20 تعليل

    A student's is_valid checks, at every node, only that the left child is smaller and the right child larger. It:

  21. W11-M21 تطبيق

    The expression tree for (2 + 3) * 4 is walked in post-order. The result is:

  22. W11-M22 تذكّر

    AVL trees and red-black trees:

19 درجات

أسئلة المقال

5 أسئلة مقالية (19 درجة). اكتب إجابتك أولًا، ثم اعرض الإجابة النموذجية ونقاط التصحيح، وقدّر درجتك بأمانة: كل نقطة تساوي درجة تقريبًا.

مجموع درجات المقال: 0 / 19

  1. W11-E1 تذكّر 3 درجات

    Define root, leaf, parent, subtree, depth and height, using the tree Q as the example for each. Why does a tree of n nodes always have exactly n - 1 edges?

  2. W11-E2 تعليل 4 درجات

    State the BST property. Give a tree in which every parent–child pair is in the right order but which is not a BST, and explain how is_valid must be designed to reject it. What is its cost?

  3. W11-E3 تعليل 4 درجات

    Describe the three cases of BST deletion. For the two-children case, explain why the in-order successor may take the deleted value's place, and why removing the successor is always easy.

  4. W11-E4 تعليل 4 درجات

    Name the four traversals of a binary tree, give the order of each, and for each say one thing it is used for and why it suits that use.

  5. W11-E5 تعليل 4 درجات

    "A BST gives O(log n) search." When is that true, and when is it false? Explain with the height, give an insertion order that makes it false, and name the cure. Compare a BST with a sorted array for search, insert and listing in order.