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

Given the binary tree above, which of the following statements\nregarding the properties of the binary tree are true (select\nall that apply)?

\n", "responses": { "root_p": "The root of the binary tree is P.", "root_e": "The root of the binary tree is E.", "root_v": "The root of the binary tree is V.", "depth_2": "The depth of the binary tree is 2.", "depth_3": "The depth of the binary tree is 3.", "depth_4": "The depth of the binary tree is 4.", "leaves_3": "The binary tree has 3 leaf nodes.", "leaves_4": "The binary tree has 4 leaf nodes.", "leaves_7": "The binary tree has 7 leaf nodes.", "full": "The binary tree is full.", "complete": "The binary tree is complete." } }, "q2": { "type": "single", "question": "\n

Given the following Python code for representing Node in a\nbinary tree:

\n\n
`\nfrom dataclasses import dataclass\nfrom typing      import Optional\n\n@dataclass\nclass Node:\n    value:  str\n    left:   Optional['Node'] = None\n    right:  Optional['Node'] = None\n`
\n\n

Which of the following lines of Python would represent the binary\ntree above?

\n", "responses": { "a": "root = Node('V', Node('A', Node('M'), Node('P')), Node('I',Node('R'), Node('E')))", "b": "root = Node('V', Node('A', Node('P'), Node('I')), Node('M',Node('R'), Node('E')))", "c": "root = Node('V', Node('M', Node('A'), Node('P')), Node('I',Node('E'), Node('R')))" } }, "q3": { "type": "order", "question": "\n

Given the binary tree above, implement the traverse\nfunction which performs an inorder traversal of the binary\ntree recursively by unscrambling the following lines of code:

\n\n
`\ndef traverse(node: Optional[Node]) -> None:\n    ...\n`
\n", "responses": { "a": "print(node.value)", "b": "traverse(node.left)", "c": "traverse(node.right)", "d": "if not Node: return" } }, "q4": { "type": "single", "question": "\n

Given the binary tree above, what is the result of a\ninorder traversal of the binary tree?

\n", "responses": { "a": "VAMPIRE", "b": "VAPIMRE", "c": "PAIVRME", "d": "PIAREMV" } }, "q5": { "type": "order", "question": "\n

Given the binary tree above, implement the traverse\nfunction which performs a preorder traversal of the binary\ntree recursively by unscrambling the following lines of code:

\n\n
`\ndef traverse(node: Optional[Node]) -> None:\n    ...\n`
\n", "responses": { "a": "print(node.value)", "b": "traverse(node.left)", "c": "traverse(node.right)", "d": "if not Node: return" } }, "q6": { "type": "single", "question": "\n

Given the binary tree above, what is the result of a\npreorder traversal of the binary tree?

\n", "responses": { "a": "VAMPIRE", "b": "VAPIMRE", "c": "PAIVRME", "d": "PIAREMV" } }, "q7": { "type": "order", "question": "\n

Given the binary tree above, implement the traverse\nfunction which performs a postorder traversal of the binary\ntree recursively by unscrambling the following lines of code:

\n\n
`\ndef traverse(node: Optional[Node]) -> None:\n    ...\n`
\n", "responses": { "a": "print(node.value)", "b": "traverse(node.left)", "c": "traverse(node.right)", "d": "if not Node: return" } }, "q8": { "type": "single", "question": "\n

Given the binary tree above, what is the result of a\npostorder traversal of the binary tree?

\n", "responses": { "a": "VAMPIRE", "b": "VAPIMRE", "c": "PAIVRME", "d": "PIAREMV" } }, "q9": { "type": "multiple", "question": "\n

Which of the following statements regarding generators in\nPython are true (select all that apply)?

\n", "responses": { "loop": "You can loop over a generator.", "index": "You can index a generator.", "store_yes": "Generators store their contents in memory.", "store_no": "Generators do not store their contents in memory.", "return": "To turn a function into a generator use the return statement.", "yield": "To turn a function into a generator use the yield statement." } } }