Free Practice Quiz Question List

6 Trees and Binary Search Trees Online Quiz Questions

Use this free practice quiz with 20 questions to review 6 Trees and Binary Search Trees, test your knowledge, and prepare for your next test or exam.

20 questions
01
Choose one
1 point

In a tree, which description correctly defines a leaf?

  1. A

    A node at depth 0

  2. B

    A node with at least one child

  3. C

    A node with no children

  4. D

    A node with two parents

02
True or false
1 point

True or false: Every node in a binary tree has at most two children.

  1. A

    True

  2. B

    False

03
Written response
1 point

What traversal visits the keys of a binary search tree in sorted order?

04
Fill in the blank
1 point

Complete the recursive node-counting rule: if node is null, count(node) returns .

05
Choose one
1 point

For the tree with root A, children B and C, B's children D and E, and C's right child F, which sequence is the preorder traversal?

  1. A

    D, B, E, A, C, F

  2. B

    A, B, D, E, C, F

  3. C

    D, E, B, F, C, A

  4. D

    A, B, C, D, E, F

06
Choose all
1 point

Select all statements that correctly describe searching a binary search tree.

  1. A

    A balanced BST can support search in O(log⁡n)O(\log n) time.

  2. B

    A skewed BST can require O(n)O(n) search time.

  3. C

    A BST search follows one root-to-leaf path rather than necessarily visiting every node.

  4. D

    Every ordinary BST guarantees O(log⁡n)O(\log n) search time.

07
Written response
1 point

In the example tree whose root is A and whose path to D is A → B → D, what is the depth of D?

08
True or false
1 point

True or false: Level-order traversal is equivalent to breadth-first search from the root and typically uses a queue.

  1. A

    True

  2. B

    False

09
Fill in the blank
1 point

When deleting a BST node with exactly one child, replace the node with .

10
Choose one
1 point

What is the auxiliary space complexity of level-order traversal when ww is the maximum number of nodes at any one level?

  1. A

    O(1)O(1)

  2. B

    O(h)O(h)

  3. C

    O(w)O(w)

  4. D

    O(n2)O(n^2)

11
Choose all
1 point

Select all statements that correctly describe important types of binary trees.

  1. A

    In a full binary tree, each node has either zero or two children.

  2. B

    In a complete binary tree, the last level is filled from left to right.

  3. C

    In a perfect binary tree, all leaves are at the same depth.

  4. D

    A degenerate tree requires every node to have two children.

12
Open ended
1 point

Why can inserting the keys 1, 2, 3, 4, and 5 into an ordinary binary search tree cause operations to take linear rather than logarithmic time?

13
Written response
1 point

A perfect binary tree has height 3, where the root has height 0. How many nodes does it contain?

14
Choose one
1 point

Consider a tree with root A. A has children B and C; B has children D and E; and C has child F. What is the depth of node F?

  1. A

    1

  2. B

    2

  3. C

    3

  4. D

    4

15
True or false
1 point

True or false: A level-order traversal processes every node at one depth before processing nodes at the next depth.

  1. A

    True

  2. B

    False

16
Choose one
1 point

A binary tree has root 1, children 2 and 3, children 4 and 5 under node 2, and only a left child 6 under node 3. How should this tree be classified?

  1. A

    Full but not complete

  2. B

    Complete but not full

  3. C

    Both full and complete

  4. D

    Neither full nor complete

17
Choose one
1 point

A binary tree has root M, left child J, right child R, right child K under J, and left child P under R. What is its preorder traversal?

  1. A

    M, J, R, K, P

  2. B

    J, K, M, P, R

  3. C

    M, J, K, R, P

  4. D

    M, R, P, J, K

18
Choose one
1 point

A binary search tree has root 8, left child 3, right child 10, right child 6 under node 3, and right child 7 under node 6. Which sequence of nodes does a search for 7 visit?

  1. A

    8, 10, 14, 13

  2. B

    8, 3, 6, 7

  3. C

    8, 3, 1, 7

  4. D

    3, 6, 7

19
Written response
1 point

Using height 0 for a one-node tree, how many nodes are in a perfect binary tree of height 3?

20
Choose one
1 point

Use height −1-1 for an empty tree. A tree has root X, children Y and Z, one child W under Y, and two children P and Q under Z. What is the height of the tree?

  1. A

    0

  2. B

    1

  3. C

    2

  4. D

    3