Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to insert a character into the Trie node's children dictionary.
DSA C#
node.Children[[1]] = new TrieNode();Attempts:
3 left
💡 Hint
Common Mistakes
Using the whole word instead of a single character.
Using the index i instead of the character at that index.
✗ Incorrect
We insert the character at index i of the word as the key in the children dictionary.
2fill in blank
mediumComplete the code to check if the current character exists in the Trie node's children.
DSA C#
if (!node.Children.ContainsKey([1])) return false;
Attempts:
3 left
💡 Hint
Common Mistakes
Checking for the whole word instead of a character.
Using the index i directly instead of the character at that index.
✗ Incorrect
We check if the children dictionary contains the current character of the word.
3fill in blank
hardFix the error in the search method to move to the next Trie node correctly.
DSA C#
node = node.Children[[1]];Attempts:
3 left
💡 Hint
Common Mistakes
Using the whole word as key instead of a character.
Using the index i instead of the character at that index.
✗ Incorrect
We must use the current character of the word to get the next node from children.
4fill in blank
hardFill both blanks to complete the Trie insertion loop correctly.
DSA C#
for (int [1] = 0; [1] < word.[2]; [1]++) { // insertion logic }
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'count' or 'len' which are not valid string properties in C#.
Using a variable name other than 'i' for the loop index.
✗ Incorrect
The loop variable is 'i' and the length property of string is 'Length' in C#.
5fill in blank
hardFill both blanks to complete the Trie search method's return statement correctly.
DSA C#
return node.[1] && index == word.[2];
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Count' which is not a string property.
Using 'IsEnd' instead of 'IsWord' for the node property.
✗ Incorrect
We check if the current node marks the end of a word with 'IsWord' and if index equals word.Length.
