Week 7: Exercises

1. Frequent Words

Write a method

string[] topWords(string filename, int n)

that reads a file and returns an array of the n most frequent words in the file, listed in descending order of frequency. If the file has fewer than n distinct words, return an array of all words in the file. Use the C# collection classes.