0
0
DSA Typescriptprogramming~10 mins

Create a Binary Tree Manually in DSA Typescript - 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 Typescript
const root = new TreeNode([1]);
Drag options to blanks, or click blank then click option'
A10
B'10'
Cnull
Dundefined
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around numbers creates a string, not a number.
Using null or undefined will not create a valid node value.
2fill in blank
medium

Complete the code to assign a left child node with value 5 to the root.

DSA Typescript
root.left = new TreeNode([1]);
Drag options to blanks, or click blank then click option'
Anull
B'5'
C5
Dundefined
Attempts:
3 left
💡 Hint
Common Mistakes
Using strings instead of numbers for node values.
Assigning null or undefined instead of a new TreeNode.
3fill in blank
hard

Fix the error in the code to assign a right child node with value 15 to the root.

DSA Typescript
root.right = new TreeNode([1]);
Drag options to blanks, or click blank then click option'
A'15'
Bundefined
Cnull
D15
Attempts:
3 left
💡 Hint
Common Mistakes
Using string '15' instead of number 15.
Assigning null or undefined instead of a TreeNode.
4fill in blank
hard

Fill both blanks to create a left child with value 3 and a right child with value 7 for the left node.

DSA Typescript
root.left.left = new TreeNode([1]);
root.left.right = new TreeNode([2]);
Drag options to blanks, or click blank then click option'
A3
B7
Cnull
Dundefined
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the values or using null/undefined.
Using strings instead of numbers.
5fill in blank
hard

Fill all three blanks to first create the right child of the root with value 15, then create its left child with value 17 and right child with value 25.

DSA Typescript
root.right = new TreeNode([3]);
root.right.left = new TreeNode([1]);
root.right.right = new TreeNode([2]);
Drag options to blanks, or click blank then click option'
A17
B25
C15
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning children before creating the parent node.
Using null instead of numbers for node values.