0
0
DSA Goprogramming~10 mins

BST Property and Why It Matters in DSA Go - 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 value should go to the left subtree in a BST.

DSA Go
if value [1] node.Value {
    // go left
}
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 subtree placement.
2fill in blank
medium

Complete the code to insert a new node in the BST when the value is greater.

DSA Go
if value [1] node.Value {
    node.Right = insert(node.Right, value)
}
Drag options to blanks, or click blank then click option'
A<=
B==
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' causes incorrect insertion on the left side.
3fill in blank
hard

Fix the error in the BST search condition to correctly find a value.

DSA Go
if node == nil || node.Value [1] value {
    return node
}
Drag options to blanks, or click blank then click option'
A>
B==
C<
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' or '<' causes wrong search results.
4fill in blank
hard

Fill both blanks to create a BST property check for left and right children.

DSA Go
if node.Left != nil && node.Left.Value [1] node.Value {
    return false
}
if node.Right != nil && node.Right.Value [2] node.Value {
    return false
}
Drag options to blanks, or click blank then click option'
A>=
B<=
C<
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up comparison operators for left and right children.
5fill in blank
hard

Fill all three blanks to build a dictionary comprehension that maps node values to their depths if depth is greater than 1.

DSA Go
depthMap := map[int]int{}
for node, depth := range nodes {
    if depth [1] 1 {
        depthMap[[2]] = [3]
    }
}
Drag options to blanks, or click blank then click option'
A>
Bdepth
Cnode
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<=' instead of '>' causes wrong filtering.