0
0
DSA Typescriptprogramming~10 mins

Binary Tree Node Structure 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 declare a class property for the node's value.

DSA Typescript
class TreeNode {
  value: [1];
  constructor(value: number) {
    this.value = value;
  }
}
Drag options to blanks, or click blank then click option'
Aboolean
Bany
Cnumber
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using string or boolean instead of number for the value type.
2fill in blank
medium

Complete the code to declare the left child property of the binary tree node.

DSA Typescript
class TreeNode {
  left: [1];
  constructor() {
    this.left = null;
  }
}
Drag options to blanks, or click blank then click option'
ATreeNode | null
Bnumber
Cboolean
Dstring
Attempts:
3 left
💡 Hint
Common Mistakes
Using just TreeNode without allowing null.
Using primitive types like number or string.
3fill in blank
hard

Fix the error in the constructor to properly initialize the right child property.

DSA Typescript
class TreeNode {
  right: TreeNode | null;
  constructor() {
    this.right = [1];
  }
}
Drag options to blanks, or click blank then click option'
Aundefined
Bnull
C0
Dfalse
Attempts:
3 left
💡 Hint
Common Mistakes
Initializing with undefined or 0 instead of null.
4fill in blank
hard

Fill both blanks to declare left and right children with correct types and initialize them to null.

DSA Typescript
class TreeNode {
  left: [1];
  right: [2];
  constructor() {
    this.left = null;
    this.right = null;
  }
}
Drag options to blanks, or click blank then click option'
ATreeNode | null
Bnumber
Cstring
Dboolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using different types for left and right children.
Not allowing null as a possible value.
5fill in blank
hard

Fill all three blanks to complete the TreeNode class with value, left, and right properties properly typed and initialized.

DSA Typescript
class TreeNode {
  value: [1];
  left: [2];
  right: [3];
  constructor(value: number) {
    this.value = value;
    this.left = null;
    this.right = null;
  }
}
Drag options to blanks, or click blank then click option'
Anumber
BTreeNode | null
Cstring
Dboolean
Attempts:
3 left
💡 Hint
Common Mistakes
Using string or boolean for value.
Not allowing null for children.