Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dance2die
Created September 16, 2017 15:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dance2die/57e7aa68fcef7a7fe8cc983d0c922422 to your computer and use it in GitHub Desktop.
Save dance2die/57e7aa68fcef7a7fe8cc983d0c922422 to your computer and use it in GitHub Desktop.
Insert a word into a trie object instance
private void Insert(TrieNode current, string word)
{
foreach (char c in word)
{
current.Children.TryGetValue(c, out TrieNode node);
if (node == null)
{
node = new TrieNode();
current.Children.Add(c, node);
}
current = node;
}
current.IsCompleteWord = true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment