private static void TestTrie() { ITrie trie = BuildTestTrie(); var words = trie.GetAllWords(); Console.WriteLine($"Total word count in trie: {words.Count}"); words = trie.GetWordsByPrefix(""); Console.WriteLine($"Total words with empty prefix: {words.Count}"); words = trie.GetWordsByPrefix("th"); Console.WriteLine($"Total words with th prefix: {words.Count}"); words = trie.GetWordsByPrefix("TH"); Console.WriteLine($"Total words with TH prefix: {words.Count}"); words = trie.GetWordsByPrefix("z"); Console.WriteLine($"Total words with z prefix: {words.Count}"); words = trie.GetWordsByPrefix("Z"); Console.WriteLine($"Total words with Z prefix: {words.Count}"); words = trie.GetWordsByPrefix("1"); Console.WriteLine($"Total words with 1 prefix: {words.Count}"); bool hasWord = trie.ContainsWord("test"); Console.WriteLine($"Word 'test' found: {hasWord}"); hasWord = trie.ContainsWord("TEST"); Console.WriteLine($"Word 'TEST' found: {hasWord}"); hasWord = trie.ContainsWord("zz"); Console.WriteLine($"Word 'zz' found: {hasWord}"); hasWord = trie.ContainsWord("ZZ"); Console.WriteLine($"Word 'ZZ' found: {hasWord}"); hasWord = trie.ContainsWord("Microsoft"); Console.WriteLine($"Word 'Microsoft' found: {hasWord}"); trie = BuildTestTrie(); words = trie.GetAllWords(); Console.WriteLine($"Total word count in trie: {words.Count}"); trie.RemoveWord("this"); words = trie.GetAllWords(); Console.WriteLine($"Total word count in trie: {words.Count}"); trie.RemoveWord("the"); words = trie.GetAllWords(); Console.WriteLine($"Total word count in trie: {words.Count}"); trie.RemoveWord("te"); words = trie.GetAllWords(); Console.WriteLine($"Total word count in trie: {words.Count}"); trie.RemoveWord("test"); words = trie.GetAllWords(); Console.WriteLine($"Total word count in trie: {words.Count}"); trie.RemoveWord("word not present"); words = trie.GetAllWords(); Console.WriteLine($"Total word count in trie: {words.Count}"); trie.RemoveWord("123"); foreach (var word in trie.GetAllWords()) { trie.RemoveWord(word); } words = trie.GetAllWords(); Console.WriteLine($"Total word count in trie: {words.Count}"); trie = BuildTestTrie(); trie.RemovePrefix("1"); words = trie.GetAllWords(); Console.WriteLine($"Total word count in trie: {words.Count}"); trie.RemovePrefix("th"); words = trie.GetAllWords(); Console.WriteLine($"Total word count in trie: {words.Count}"); trie.RemovePrefix("x"); words = trie.GetAllWords(); Console.WriteLine($"Total word count in trie: {words.Count}"); trie.RemovePrefix(""); words = trie.GetAllWords(); Console.WriteLine($"Total word count in trie: {words.Count}"); }