Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new node with value 10.
DSA Javascript
const node = { value: [1], left: null, right: null }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '10' as a string instead of 10 as a number.
Setting value to null or undefined.
✗ Incorrect
The value of the node should be the number 10, not a string or null.
2fill in blank
mediumComplete the code to assign the left child of the root node to a new node with value 5.
DSA Javascript
root.left = { value: [1], left: null, right: null }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '5' as a string instead of 5 as a number.
Assigning null or undefined instead of a node.
✗ Incorrect
The left child node should have the numeric value 5.
3fill in blank
hardFix the error in the code to assign the right child of the root node to a new node with value 15.
DSA Javascript
root.right = { value: [1], left: null, right: null }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '15' as a string instead of 15 as a number.
Assigning null or undefined instead of a node.
✗ Incorrect
The value should be the number 15, not a string or null.
4fill in blank
hardFill both blanks to create a root node with value 20 and assign its left child with value 10.
DSA Javascript
const root = { value: [1], left: { value: [2], left: null, right: null }, right: null }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings like '10' instead of numbers.
Setting left or root value to null.
✗ Incorrect
The root value is 20 and the left child value is 10, both as numbers.
5fill in blank
hardFill all three blanks to create a root node with value 30, left child 20, and right child 40.
DSA Javascript
const root = { value: [1], left: { value: [2], left: null, right: null }, right: { value: [3], left: null, right: null } }; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using null instead of numbers for values.
Using strings instead of numbers.
✗ Incorrect
The root is 30, left child 20, and right child 40, all numbers.