0
0
DSA Typescriptprogramming~10 mins

BST Property and Why It Matters 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 check if a node's left child value is greater than or equal to the node's value.

DSA Typescript
if (node.left && node.left.value [1] node.value) {
  return false;
}
Drag options to blanks, or click blank then click option'
A>=
B<
C>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '<=' instead of '>=' causes incorrect BST validation.
Confusing left and right child comparisons.
2fill in blank
medium

Complete the code to check if a node's right child value is less than or equal to the node's value.

DSA Typescript
if (node.right && node.right.value [1] node.value) {
  return false;
}
Drag options to blanks, or click blank then click option'
A>
B<
C>=
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' or '>=' instead of '<=' causes wrong BST validation.
Mixing up left and right child checks.
3fill in blank
hard

Fix the error in the BST validation condition for the left subtree.

DSA Typescript
return isBST(node.left, [1], node.value) && isBST(node.right, node.value, max);
Drag options to blanks, or click blank then click option'
Anull
Bnode.value
Cmin
Dmax
Attempts:
3 left
💡 Hint
Common Mistakes
Passing node.value as min causes incorrect range checks.
Using max instead of min for left subtree boundaries.
4fill in blank
hard

Fill both blanks to complete the BST validation recursive calls with correct boundaries.

DSA Typescript
return isBST(node.left, [1], node.value) && isBST(node.right, node.value, [2]);
Drag options to blanks, or click blank then click option'
Amin
Bmax
Cnode.value
Dnull
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping min and max in recursive calls.
Using node.value for both boundaries.
5fill in blank
hard

Fill all three blanks to complete the BST property check in the recursive function.

DSA Typescript
if (!node) return true;
if (node.value [1] min || node.value [2] max) return false;
return isBST(node.left, min, [3]) && isBST(node.right, node.value, max);
Drag options to blanks, or click blank then click option'
A<=
B>=
Cnode.value
Dmin
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' or '>' instead of '<=' or '>=' causes boundary errors.
Passing min instead of node.value as new max boundary.