0
0
DSA Goprogramming~10 mins

Trie Search Operation 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 the current character exists in the children map.

DSA Go
if _, ok := node.children[[1]]; !ok {
    return false
}
Drag options to blanks, or click blank then click option'
Anode
Bword
Ci
Dword[i]
Attempts:
3 left
💡 Hint
Common Mistakes
Using the whole word instead of a single character.
Using the index i directly instead of word[i].
2fill in blank
medium

Complete the code to move to the next node in the trie for the current character.

DSA Go
node = node.children[[1]]
Drag options to blanks, or click blank then click option'
Ai
Bnode
Cword[i]
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the index i instead of the character word[i].
Using the whole word instead of a single character.
3fill in blank
hard

Fix the error in the return statement to check if the word ends here.

DSA Go
return node.[1]
Drag options to blanks, or click blank then click option'
AisEnd
BisWord
Cend
DwordEnd
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect field names like isEnd or end.
Returning the wrong property that does not indicate word end.
4fill in blank
hard

Fill both blanks to complete the for loop iterating over the word characters.

DSA Go
for [1] := 0; [2] < len(word); [1]++ {
    // loop body
}
Drag options to blanks, or click blank then click option'
Ai
Bj
Dk
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variables in initialization and condition.
Using variables not declared in the loop.
5fill in blank
hard

Fill all three blanks to complete the search function signature and return type.

DSA Go
func (t *Trie) [1](word string) [2] {
    node := t.root
    for i := 0; i < len(word); i++ {
        if _, ok := node.children[word[i]]; !ok {
            return [3]
        }
        node = node.children[word[i]]
    }
    return node.isWord
}
Drag options to blanks, or click blank then click option'
ASearch
Bbool
Cfalse
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect function names.
Returning true instead of false when word not found.
Wrong return type.