encryption algorithm for finding the most frequent word
Today my task is to implement the program which inputs the name of the file and outputs the most frequent word in the textfile.
Limits: max - 50000 word, each word max - 30 chars.
So here is how im trying to implement it.
1) count the number of words (N)
2) malloc the integer array with the size of N
3) read the word by word
4) encrypt the word so that the encryption algorithm generates the unique integer which is less than N
5) increase the value of array in index of the generated integer
for example generated integer = 1234... then a++
6) at the end, decrypt the index which has the greatest value
7) output it
So, does anyone know such an algorithm? or any other suggestions are welcome!
Thanks in advance!