Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a simple array of integers.
DSA Rust
let numbers = [1, 2, 3, 4, [1]];
Attempts:
3 left
💡 Hint
Common Mistakes
Using a number not matching the sequence.
Leaving the blank empty.
✗ Incorrect
The array ends with the number 5, so the blank should be filled with 5.
2fill in blank
mediumComplete the code to create a linked list node with a value.
DSA Rust
struct Node {
value: i32,
next: Option<Box<Node>>,
}
let node = Node { value: [1], next: None };Attempts:
3 left
💡 Hint
Common Mistakes
Using a value not matching the example.
Confusing next with value.
✗ Incorrect
The node's value is set to 20 as per the example.
3fill in blank
hardFix the error in the tree node creation by filling the correct child node value.
DSA Rust
struct TreeNode {
value: i32,
left: Option<Box<TreeNode>>,
right: Option<Box<TreeNode>>,
}
let root = TreeNode {
value: 1,
left: Some(Box::new(TreeNode { value: [1], left: None, right: None })),
right: None,
};Attempts:
3 left
💡 Hint
Common Mistakes
Using a value other than 2 for the left child.
Leaving the child node value blank.
✗ Incorrect
The left child node value is 2 to maintain the example tree structure.
4fill in blank
hardFill both blanks to create a linked list node that points to another node.
DSA Rust
let second = Node { value: 20, next: None };
let first = Node { value: 10, next: [1] };Attempts:
3 left
💡 Hint
Common Mistakes
Using None instead of Some(Box::new(...)).
Not boxing the node.
✗ Incorrect
The first node's next points to the second node wrapped in Some and Box.
5fill in blank
hardFill all three blanks to create a tree node with left and right children.
DSA Rust
let left_child = TreeNode { value: [1], left: None, right: None };
let right_child = TreeNode { value: [2], left: None, right: None };
let root = TreeNode {
value: [3],
left: Some(Box::new(left_child)),
right: Some(Box::new(right_child)),
};Attempts:
3 left
💡 Hint
Common Mistakes
Swapping left and right child values.
Using root value same as children.
✗ Incorrect
Left child is 2, right child is 3, root is 1 to form a simple tree.
