private void PrintDfs(Trie trie, string spaces) { Console.WriteLine("{0}{1}", spaces, trie.root); foreach (var child in trie.children) { if (child != null) { PrintDfs(child, spaces + " "); } } }
public static void Main(string[] args) { Trie trie = new Trie(); trie.AddWord("tea"); trie.AddWord("ted"); trie.AddWord("terrible"); trie.AddWord("ten"); trie.AddWord("terrific"); trie.AddWord("tenaciuos"); trie.AddWord("tenant"); trie.AddWord("what"); trie.PrintDfs(); }