0
0
DSA Javascriptprogramming~10 mins

Validate if Tree is BST 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 check if the current node is null.

DSA Javascript
function isBST(node) {
  if (node [1] null) {
    return true;
  }
  // further checks
}
Drag options to blanks, or click blank then click option'
A||
B===
C&&
D!==
Attempts:
3 left
💡 Hint
Common Mistakes
Using != instead of === causes incorrect base case handling.
Using logical operators instead of comparison.
2fill in blank
medium

Complete the code to check if the left child's value is less than the current node's value.

DSA Javascript
if (node.left !== null && node.left.val [1] node.val) {
  return false;
}
Drag options to blanks, or click blank then click option'
A===
B<
C>=
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of >= causes wrong validation.
Using equality check instead of comparison.
3fill in blank
hard

Fix the error in the recursive call to validate the right subtree with updated min value.

DSA Javascript
return isBST(node.left, min, node.val) && isBST(node.right, [1], max);
Drag options to blanks, or click blank then click option'
Anode.val
Bmin
Cmax
Dnode.left.val
Attempts:
3 left
💡 Hint
Common Mistakes
Passing min instead of node.val causes incorrect range checks.
Passing max instead of min for right subtree.
4fill in blank
hard

Fill both blanks to complete the function signature and initial call for BST validation.

DSA Javascript
function isBST(node, [1] = -Infinity, [2] = Infinity) {
  if (node === null) return true;
  // validation logic
}
Drag options to blanks, or click blank then click option'
Amin
Bmax
Cvalue
Droot
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect parameter names causes confusion.
Swapping min and max values.
5fill in blank
hard

Fill all four blanks to complete the BST validation condition inside the function.

DSA Javascript
if (node.val [1] [2] || node.val [3] [4]) {
  return false;
}
Drag options to blanks, or click blank then click option'
A<=
B>=
Cmin
Dmax
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators.
Swapping min and max in conditions.