0
0
DSA Typescriptprogramming~10 mins

BST Find Minimum Element 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 return the left child of the current node.

DSA Typescript
return node[1];
Drag options to blanks, or click blank then click option'
A.left
B.right
C.parent
D.value
Attempts:
3 left
💡 Hint
Common Mistakes
Returning node.right instead of node.left
Returning node.value instead of a node reference
2fill in blank
medium

Complete the code to check if the current node has no left child.

DSA Typescript
if (node[1] === null) {
Drag options to blanks, or click blank then click option'
A.right
B.value
C.parent
D.left
Attempts:
3 left
💡 Hint
Common Mistakes
Checking node.right instead of node.left
Comparing node.value to null
3fill in blank
hard

Fix the error in the recursive call to find the minimum node.

DSA Typescript
return findMin(node[1]);
Drag options to blanks, or click blank then click option'
A.right
B.parent
C.left
D.value
Attempts:
3 left
💡 Hint
Common Mistakes
Using node.right in recursion
Using node.value instead of a node reference
4fill in blank
hard

Fill both blanks to complete the iterative search for the minimum node.

DSA Typescript
while (current[1] !== null) {
  current = current[2];
}
Drag options to blanks, or click blank then click option'
A.left
B.right
C.parent
D.value
Attempts:
3 left
💡 Hint
Common Mistakes
Using right child in the loop condition or update
Using node.value instead of node reference
5fill in blank
hard

Fill all three blanks to complete the function that finds the minimum node recursively.

DSA Typescript
function findMin(node: TreeNode | null): TreeNode | null {
  if (node === null || node[1] === null) {
    return node;
  }
  return findMin(node[2]);
}

const minNode = findMin(root[3]);
Drag options to blanks, or click blank then click option'
A.left
B.right
C.parent
D.value
Attempts:
3 left
💡 Hint
Common Mistakes
Using node.right instead of node.left
Adding extra property after root in the last blank