Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare an array of integers with size 5.
DSA Java
int[] numbers = new int[[1]];Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 as size creates an empty array.
Using 1 or 10 creates arrays of wrong size.
✗ Incorrect
The array size must be 5 to hold five integers.
2fill in blank
mediumComplete the code to add a new node with value 10 at the end of a singly linked list.
DSA Java
Node newNode = new Node([1]);
current.next = newNode;Attempts:
3 left
💡 Hint
Common Mistakes
Using null instead of a value causes errors.
Using 0 or 5 does not match the required value.
✗ Incorrect
The new node should hold the value 10 as specified.
3fill in blank
hardFix the error in the tree node creation by completing the missing child assignment.
DSA Java
TreeNode root = new TreeNode(1); root.left = new TreeNode([1]);
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning null means no child node is created.
Using 0 or root causes logical errors.
✗ Incorrect
The left child node should have value 2 to build the tree correctly.
4fill in blank
hardFill both blanks to create a linked list node and link it properly.
DSA Java
Node newNode = new Node([1]); current.[2] = newNode;
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' instead of 'next' breaks singly linked list logic.
Using 'data' as a pointer is incorrect.
✗ Incorrect
The new node holds value 15 and is linked by setting current.next to newNode.
5fill in blank
hardFill all three blanks to create a tree node with value 20 and assign its left and right children.
DSA Java
TreeNode node = new TreeNode([1]); node.left = new TreeNode([2]); node.right = new TreeNode([3]);
Attempts:
3 left
💡 Hint
Common Mistakes
Using null for children creates missing nodes.
Swapping left and right child values breaks tree order.
✗ Incorrect
The root node has value 20, left child 15, and right child 25 to form a proper binary tree.
