-5

Looking for pseudo code to help me figure this question out:

After processing the text file into your concordance you will print all of the words and their counts. Print one word-count pair per line.

So if the text file had two "and"s it would print and:2, not and:1, and:2.

count = 1;
if (*value > 1){ //finds all words repeated at least once
    count++;
printf("%s:%d\n, word, count):

??

1 Answers1

1

If the file is not big enough, you can store each word of the file in a hashtable which would store words as keys and their count as values. If there is a hash collision or the word is already in hash table, increment count else keep on adding new words into hash.

priteshbaviskar
  • 2,139
  • 2
  • 20
  • 27