{ "q1": { "type": "multiple", "question": "\n

Which of the following binary trees are binary search\ntrees (select all that apply)?

\n\n
\n \n
\n", "responses": { "a": "A", "b": "B", "c": "C" } }, "q2": { "type": "multiple", "question": "\n

Which of the following statements regarding binary search trees\nare true (select all that apply)?\n", "responses": { "bst_array": "Binary search trees are usually represented using an array.", "bst_nodes": "Binary search trees are usually represented using linked nodes.", "bst_full": "Binary search trees must be full trees.", "bst_complete": "Binary search trees must be complete trees.", "bst_root": "The root of a binary search tree is always the smallest or largest value in the tree.", "bst_middle": "The root of a binary search tree is always a middle value in the tree.", "bst_avg_logn": "In the average case, adding a new value to a binary search tree is an O(logn) operation.", "bst_avg_n": "In the average case, adding a new value to a binary search tree is an O(n) operation.", "bst_worst_logn": "In the worst case, adding a new value to a binary search tree is an O(logn) operation.", "bst_worst_n": "In the worst case, adding a new value to a binary search tree is an O(n) operation." } }, "q3": { "type": "blank", "question": "\n

Given the following Node class:

\n\n
\n@dataclass\nclass Node:\n    value:  int\n    left:   Optional['Node'] = None\n    right:  Optional['Node'] = None\n
\n\n

Complete the following recursive implementation of bst_search:

\n\n
\ndef bst_search(root: Optional[Node], value: int) -> bool:\n    if root is ____:  return False  # Base case: Invalid Node\n\n    if value == ____: return True   # Base case: Found Node\n\n    if ____:                        # Recursive: Search left\n        return ____\n    else:                           # Recursive: Search right\n        return ____\n
\n" }, "q4": { "type": "multiple", "question": "\n

Suppose we have the following binary search tree and we insert a\nnew Node with the value 6. Which of the following\nstatements are true (select all that apply)?

\n\n
\n \n
\n", "responses": { "root_5": "After the insert(), the root is 5.", "root_6": "After the insert(), the root is 6.", "parent_3": "After the insert(), the parent of the new Node is 3.", "parent_7": "After the insert(), the parent of the new Node is 7." } }, "q5": { "type": "single", "question": "\n

Both treaps and red-black trees require rotations\nto balance the binary search tree. Given the binary search\ntree below, what would it look like after a left rotation around the\nroot.

\n\n
\n \n
\n", "responses": { "a": "A", "b": "B", "c": "C", "d": "D" } }, "q6": { "type": "single", "question": "\n

Both treaps and red-black trees require rotations\nto balance the binary search tree. Given the binary search\ntree below, what would it look like after a right rotation around\nthe root.

\n\n
\n \n
\n", "responses": { "a": "A", "b": "B", "c": "C", "d": "D" } }, "q7": { "type": "multiple", "question": "\n

Which of the following statements regarding treaps and\nred-black trees are true (select all that apply)?

\n", "responses": { "treap_insert_avg": "On average, insertion into a treap is O(log(n)).", "rbtree_insert_avg": "On average, insertion into a red-black tree is O(log(n)).", "treap_insert_worst": "In the worst case, insertion into a treap is O(log(n)).", "rbtree_insert_worst": "In the worst case, insertion into a red-black tree is O(log(n)).", "treap_rotations": "Treaps use rotations to balance the binary search tree.", "rbtree_rotations": "Red-black trees use rotations to balance the binary search tree.", "treap_hybrid": "Treaps are a hybrid data structure that combine binary heaps and binary search trees.", "rbtree_hybrid": "Red-black trees are a hybrid data structure that combine binary heaps and binary search trees." } } }