Sunday, June 16, 2013

What will be the approach to find the word which occurs maximum number of times in a very large file. (C#)

To find a word that occurs the maximum number of times in a very large file, the entire file will have to be scanned for the occurrence of the word. Since the file is very large, it will be efficient to process the file and find the occurrence of the word asynchronously. After the file is read in a fileStream, we can have different threads to process the file in chunks simultaneously. The threads will wait till processing for the file in each thread is over. Then the word with maximum count in the file will be determined.

No comments: