?
Following code snippet is the function to insert a string in a trie. Find the missing line.
Following code snippet is the function to insert a string in a trie. Find the missing line.
private void insert(String str)
{
TrieNode node = root;
for (int i = 0; i < length; i++)
{
int index = key.charAt(i) - 'a';
if (node.children[index] == null)
node.children[index] = new TrieNode();
________________________
}
node.isEndOfWord = true;
}
private void insert(String str)
{
TrieNode node = root;
for (int i = 0; i < length; i++)
{
int index = key.charAt(i) - 'a';
if (node.children[index] == null)
node.children[index] = new TrieNode();
________________________
}
node.isEndOfWord = true;
}
Join the Discussion
Login to post a comment or share your explanation.
Login