Шукаєте відповіді та рішення тестів для MATH348 - Graph Theory and Application SEJ G1 - F26? Перегляньте нашу велику колекцію перевірених відповідей для MATH348 - Graph Theory and Application SEJ G1 - F26 в moodle.medtech.tn.
Отримайте миттєвий доступ до точних відповідей та детальних пояснень для питань вашого курсу. Наша платформа, створена спільнотою, допомагає студентам досягати успіху!
Given the TreeNode structure built in Part 3:
root = TreeNode("A")
b, c, d, e, f = [TreeNode(x) for x in "BCDEF"]
root.add_child(b)
root.add_child(c)
root.add_child(d)
c.add_child(e)
c.add_child(f)
What are the expected outputs of preorder(root) and postorder(root) respectively?
Using the action history tree from Part 5, what are the values of match.value for:
match1 = find_node(history, "Delete line")
match2 = find_node(history, "Save file")
In Part 1 of the lab, you are given the following graph representation:
tree = {
1: {2},
2: {1, 3, 4},
3: {2},
4: {2, 5, 6},
5: {4},
6: {4}
}
What is the exact list returned by calling prufer_encode(tree)?
In the lab, you perform the following round-trip verification test:
seq = [2, 4, 4, 2]
decoded_tree = prufer_decode(seq)
print(prufer_encode(decoded_tree) == seq)
If both functions are implemented correctly, what is printed?
In the TODO instructions for prufer_encode(tree), why is step 1 instructed to copy the adjacency sets of the dictionary?
For values = [10, 20, 30, 40, 50, 60], what list does array_preorder(values) return?
(Format answer exactly as a Python list string, e.g. [1, 2, 3])
In prufer_decode(sequence), after processing all elements in the input sequence list, what final step completes the graph reconstruction?
In Part 4, you write the recursive inner function visit(i) for array_preorder(values):
def array_preorder(values):
result = []
def visit(i):
# TODO
pass
if values:
visit(0)
return result
Which recursive call pattern correctly fills result in preorder for an array representation?
In Part 3, you construct a binary tree using BinaryNode:
binary_root = BinaryNode(
8,
BinaryNode(3, BinaryNode(1), BinaryNode(6)),
BinaryNode(10, None, BinaryNode(14))
)
What list does inorder(binary_root) produce?
In Part 5, you implement find_node(node, target) to perform Depth-First Search on an action history tree:
history = TreeNode("Start")
type_text = TreeNode("Type text")
open_file = TreeNode("Open file")
add_title = TreeNode("Add title")
delete_line = TreeNode("Delete line")
history.add_child(type_text)
history.add_child(open_file)
type_text.add_child(add_title)
type_text.add_child(delete_line)
Which Python snippet correctly implements DFS to locate a target node?