0
0
Agentic AIml~10 mins

Tree-of-thought for complex decisions in Agentic AI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to start a tree-of-thought search with an initial state.

Agentic AI
tree = TreeOfThought(initial_state=[1])
Drag options to blanks, or click blank then click option'
Astart_state
Binitial_state
Croot_state
Dstate0
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names that are not recognized by the TreeOfThought constructor.
Confusing the initial state with other variable names.
2fill in blank
medium

Complete the code to expand the current node by generating possible next thoughts.

Agentic AI
next_nodes = current_node.[1]()
Drag options to blanks, or click blank then click option'
Aexpand
Bbranch
Cgrow
Dgenerate
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names that do not exist on the node object.
Confusing expansion with evaluation or selection.
3fill in blank
hard

Fix the error in the code to correctly evaluate the utility of a node.

Agentic AI
score = node.evaluate_utility([1])
Drag options to blanks, or click blank then click option'
Ascore_function
Butility_score
Cevaluate
Dheuristic_function
Attempts:
3 left
💡 Hint
Common Mistakes
Passing a numeric score instead of a function.
Using incorrect parameter names that cause runtime errors.
4fill in blank
hard

Fill both blanks to select the best child node based on utility and update the current node.

Agentic AI
best_child = max(current_node.children, key=lambda n: n.[1])
current_node = current_node.[2](best_child)
Drag options to blanks, or click blank then click option'
Autility_score
Bselect_child
Cevaluate_utility
Dmove_to
Attempts:
3 left
💡 Hint
Common Mistakes
Using a method instead of an attribute for the key function.
Trying to assign the current node without using the proper method.
5fill in blank
hard

Fill all three blanks to implement a recursive tree-of-thought search with depth limit.

Agentic AI
def tree_search(node, depth):
    if depth == 0 or node.is_terminal():
        return node.[1]()
    best_score = float('-inf')
    best_action = None
    for child in node.[2]():
        score = tree_search(child, depth - 1)
        if score > best_score:
            best_score = score
            best_action = child
    return node.[3](best_action)
Drag options to blanks, or click blank then click option'
Aevaluate_utility
Bexpand
Cselect_child
Dgenerate
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up method names for generating children and selecting best child.
Returning the wrong value at the base case.