0
0
DSA Javascriptprogramming~10 mins

Create a Binary Tree Manually in DSA Javascript - Interactive Practice

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

Complete 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'
A10
B'10'
Cnull
Dundefined
Attempts:
3 left
💡 Hint
Common Mistakes
Using '10' as a string instead of 10 as a number.
Setting value to null or undefined.
2fill in blank
medium

Complete 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'
A5
Bnull
C'5'
Dundefined
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.
3fill in blank
hard

Fix 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'
A'15'
B15
Cnull
Dundefined
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.
4fill in blank
hard

Fill 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'
A20
B10
Cnull
D'10'
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings like '10' instead of numbers.
Setting left or root value to null.
5fill in blank
hard

Fill 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'
A30
B20
C40
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Using null instead of numbers for values.
Using strings instead of numbers.