Data Structures u0026 Algorithms: Complex Tree Traversals and Core Binary Tree Concepts Quiz

This quiz challenges your understanding of advanced binary tree traversals, properties, and algorithms such as finding diameter, lowest common ancestor, and calculating height. Test your knowledge with scenarios and in-depth questions.

  1. Question 1

    Given a binary tree where each node contains a unique value, which traversal order will always visit the root node before any other node?

    1. Levelorder
    2. Inorder
    3. Preorder
    4. Postorder
    5. Reverse Inorder
  2. Question 2

    For a skewed binary tree where every node has only a right child (forming a linked list), what is the difference between its inorder and postorder traversals?

    1. Inorder produces the reversed sequence of postorder
    2. Postorder always skips the rightmost node
    3. Postorder visits the leftmost node first while inorder visits the root first
    4. Both traversals will produce the same sequence
    5. Inorder only contains root nodes, postorder contains leaves
  3. Question 3

    If F is the root of a binary tree, and its left and right subtrees have heights 4 and 7 respectively, what is the minimum possible height of this tree?

    1. 6
    2. 8
    3. 5
    4. 9
    5. 7
  4. Question 4

    Given a binary tree, what is the precise definition of its diameter?

    1. The sum of the heights of left and right subtrees
    2. The maximum number of nodes on any root-to-leaf path
    3. The maximum number of edges between any two nodes
    4. The minimum depth among all leaves
    5. The total number of internal nodes
  5. Question 5

    Which traversal, when run on a binary search tree, will output the node values in sorted ascending order?

    1. Preorder
    2. Inorder
    3. Morris Preorder
    4. Reverse Levelorder
    5. Postorder
  6. Question 6

    In a level order traversal of a binary tree with N nodes, what is the worst-case time complexity, assuming the tree is unbalanced?

    1. O(log N)
    2. O(1)
    3. O(N^2)
    4. O(N)
    5. O(N log N)
  7. Question 7

    If two nodes in a binary tree are the same node, what is their lowest common ancestor (LCA)?

    1. That node itself
    2. There is no LCA in this case
    3. The parent of the node
    4. The root node
    5. Always a leaf node
  8. Question 8

    Consider the binary tree whose inorder and preorder traversals are: Inorder: D B A E C, Preorder: A B D C E. What is the left child of root?

    1. D
    2. E
    3. C
    4. B
    5. A
  9. Question 9

    Which property distinguishes a complete binary tree from a full binary tree?

    1. All leaves have the same depth
    2. Every level, except possibly the last, is completely filled and all nodes are as far left as possible
    3. Each node has exactly two or zero children
    4. The tree contains only one root
    5. Each parent has at least one child
  10. Question 10

    If the height function of a node is defined as the number of edges on the longest path to a leaf, what is the height of a leaf node?

    1. Leaf nodes have height -1
    2. Depends on the subtree
    3. Undefined
    4. 0
    5. 1