Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new node with value 10.
DSA Python
class Node: def __init__(self, data): self.data = data self.left = None self.right = None root = Node([1])
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around 10, which makes it a string instead of an integer.
Assigning None instead of a value.
✗ Incorrect
The root node should be created with the integer value 10, not a string or None.
2fill in blank
mediumComplete the code to assign a left child node with value 5 to the root.
DSA Python
root.left = Node([1])Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around 5, making it a string.
Assigning None instead of a node.
✗ Incorrect
The left child node should be created with the integer value 5.
3fill in blank
hardFix the error in assigning the right child node with value 15 to the root.
DSA Python
root.right = Node([1])Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around 15, making it a string.
Assigning None instead of a node.
✗ Incorrect
The right child node should be created with the integer value 15, not a string or None.
4fill in blank
hardFill both blanks to assign left and right children to the left child node.
DSA Python
root.left.left = Node([1]) root.left.right = Node([2])
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings instead of integers for node values.
Mixing up left and right child assignments.
✗ Incorrect
The left and right children of root.left should be nodes with integer values 3 and 7 respectively.
5fill in blank
hardFill all three blanks to assign left, right children to right child node and print root data.
DSA Python
root.right.left = Node([1]) root.right.right = Node([2]) print(root[3])
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings instead of integers for node values.
Printing root without .data to access the value.
✗ Incorrect
Assign 13 and 20 as left and right children of root.right, and print root.data to show root node value.
