Complete the code to insert a character into the Trie node's children.
node.children[[1]] = TrieNode()The character char is used as the key to insert a new TrieNode into the children dictionary.
Complete the code to check if a character exists in the current Trie node's children during search.
if [1] in node.children:
We check if the current character char exists in the children of the current node.
Fix the error in the code that marks the end of a word in the Trie after insertion.
node.[1] = True
The standard attribute to mark the end of a word in a Trie node is is_end_of_word.
Fill both blanks to complete the dictionary comprehension that creates a mapping of characters to Trie nodes for a given word.
{ [1]: TrieNode() for [2] in word }The comprehension maps each char in the word to a new TrieNode.
Fill all three blanks to complete the search function that returns True if the word exists in the Trie.
def search(word): node = root for [1] in word: if [2] not in node.children: return False node = node.children[[3]] return node.is_end_of_word
Each blank should be filled with char because the loop iterates over characters, and the search checks and moves along those characters in the Trie.