private void AddWordInDictionary(ref TimDictionary[] dictionary, string word, int i)
 {
     Array.Resize(ref dictionary, dictionary.Length + 1);
     IncrementWithOneAtPositionI(dictionary, i);
     dictionary[i].word = word;
     dictionary[i].occurency = 1;
 }
 private static bool WordIsFirstOrLast(string word, TimDictionary[] dictionary)
 {
     int lastIndex = dictionary.Length - 1;
     int firstIndex = 0;
     return string.Equals(dictionary[lastIndex].word, word) ||
                     string.Equals(dictionary[firstIndex].word, word);
 }
 private bool ExistWord(string word, TimDictionary[] dictionary)
 {
     for(int i = 0; i < dictionary.Length; i++)
     {
         if (string.Equals(dictionary[i].word, word, StringComparison.CurrentCultureIgnoreCase))
             return true;
      }
     return false;
 }
 private TimDictionary[] AddWordInAlphabeticalOrder(TimDictionary[] dictionary, string word)
 {
     for (int i = 0; i < dictionary.Length; i++)
         if (ThisWordIsBeforeTheOneFromDictionary(word, dictionary[i].word))
         {
             AddWordInDictionary(ref dictionary, word, i);
             return dictionary;
         }
     AddWordInDictionary(ref dictionary, word, dictionary.Length - 1);
     return dictionary;
 }
 private int GiveMeIndex(string word, TimDictionary[] dictionary)
 {
     for (int i = 0; i < dictionary.Length; i++)
     {
         if(string.Equals(dictionary[i].word, word, StringComparison.CurrentCultureIgnoreCase))
             return i;
     }
     return 0;
 }
 private void Swap(ref TimDictionary[] dictionary, int j)
 {
     var temp = dictionary[j];
     dictionary[j] = dictionary[j - 1];
     dictionary[j - 1] = temp;
 }
 private TimDictionary[] SortByOccurency(TimDictionary[] dictionary)
 {
     for (int i = 1; i < dictionary.Length; i++)
         for (int j = i; j > 0 && (dictionary[j].occurency > dictionary[j - 1].occurency); j--)
             Swap(ref dictionary, j);
     return dictionary;
 }
 private static void IncrementWithOneAtPositionI(TimDictionary[] dictionary, int i)
 {
     if (i < (dictionary.Length - 1))
         Array.Copy(dictionary, i, dictionary, i + 1, dictionary.Length - i - 1);
 }
        private bool WordExist(string word, TimDictionary[] dictionary)
        {
            if (WordIsFirstOrLast(word, dictionary))
                return true;

            int lastIndex = dictionary.Length - 1;
            int firstIndex = 0;
            while (lastIndex - firstIndex > 1)
            {
                int halfIndex = (lastIndex + firstIndex) / 2;

                if (string.Equals(dictionary[halfIndex].word, word))
                    return true;
                if (ThisWordIsBeforeTheOneFromDictionary(word, dictionary[halfIndex].word))
                    lastIndex = halfIndex;
                else
                    firstIndex = halfIndex;
            }
            return false;
        }