static void Main() { Stopwatch sw = new Stopwatch(); TrieNode start = new TrieNode(); Dictionary <string, int> wordsInDictionary = new Dictionary <string, int>(); var allWords = SetInputText(); List <string> wordsToSearch = new List <string>(); // change number to increase searched words count for (int i = 0; i < 50; i++) { wordsToSearch.Add(allWords[i].ToString()); } AddWordsForSearchInDictionary(sw, wordsToSearch, wordsInDictionary); AddWordsForSearchInTrie(sw, start, wordsToSearch); IncrementOccuranceCountTrie(sw, start, allWords); IncrementOccuranceCountDictionary(sw, wordsInDictionary, allWords); Console.WriteLine("Searched words count trie: "); foreach (var word in wordsToSearch) { Console.WriteLine("{0}: {1}", word, start.CountWords(start, word)); } Console.WriteLine("\nSearched words count dictionary: "); foreach (var item in wordsInDictionary) { Console.WriteLine("{0}: {1}", item.Key, item.Value); } }
static void Main(string[] args) { ///=========================================== ///Unzip the archive in the project directory ///=========================================== Stopwatch sw = new Stopwatch(); TrieNode start = new TrieNode(); Dictionary<string, int> wordsInDictionary = new Dictionary<string, int>(); var allWords = SetInputText(); List<string> wordsToSearch = new List<string>(); // change number to increase searched words count for (int i = 0; i < 50; i++) { wordsToSearch.Add(allWords[i].ToString()); } AddWordsForSearchInDictionary(sw, wordsToSearch, wordsInDictionary); AddWordsForSearchInTrie(sw, start, wordsToSearch); IncrementOccuranceCountTrie(sw, start, allWords); IncrementOccuranceCountDictionary(sw, wordsInDictionary, allWords); Console.WriteLine("Searched words count trie: "); foreach (var word in wordsToSearch) { Console.WriteLine("{0}: {1}", word, start.CountWords(start, word)); } Console.WriteLine("\nSearched words count dictionary: "); foreach (var item in wordsInDictionary) { Console.WriteLine("{0}: {1}", item.Key, item.Value); } }