The problem is: Given a list of strings and an integer k, return the top k most frequently occurring words in descending order based on frequency. This must be done O(N) where N is the length of the list of strings.
The popular solution is to store (word, frequency) in a hash table, sort the hash table by frequency, and output the top k words. This is not O(N) however because sorting by frequency takes O(NlgN).
I'm wondering if a O(N) solution actually exists. I've thought about quick-select where you get the kth top most occurring word and sort the remaining frequencies but that would be O(N + klgk) which is still O(NlgN) when k is say N.