Complete the code to check if the current node marks the end of a word in the Trie.
return current.[1];
The isEndOfWord boolean indicates if the current node marks the end of a stored word in the Trie.
Complete the code to move to the child node corresponding to the current character during search.
current = current.children[[1] - 'a'];
We use the character c from the word to find the correct child node by subtracting 'a' to get the index.
Fix the error in the search loop condition to correctly iterate over the characters of the word.
for (int i = 0; i [1] word.length(); i++) {
The loop should run while i is less than the length of the word to avoid index out of bounds.
Fill both blanks to check if the child node exists and move to it during search.
if (current.children[[1] - 'a'] == [2]) { return false; }
true instead of null.We check if the child node for character c is null. If yes, the word is not in the Trie.
Fill all three blanks to complete the search method that returns true if the word exists in the Trie.
public boolean search(String word) {
TrieNode current = root;
for (int [1] = 0; [2] < word.length(); [3]++) {
char c = word.charAt(i);
if (current.children[c - 'a'] == null) {
return false;
}
current = current.children[c - 'a'];
}
return current.isEndOfWord;
}The loop variable i is used for initialization, condition, and increment to iterate over the word characters.
