Algorithm to find top 10 search terms in search engine

**Problem : ** “You have been asked to design some software to continuously display the top 10 search terms on Google (or any other search engine). You are given access to a feed that provides an endless real-time stream of search terms currently being searched on Google. Describe what algorithm and data structures you would use to implement this. You are to design two variations: (i) Display the top 10 search terms of all time (i. [Read More]

Find the k most frequent words from a file

Case 1 - Consider the file is not big The question can be described as: Input: A positive integer K and a text file which can stay in-memory. The text can actually be viewed as word sequence. So we don’t have to worry about how to break down it into word sequence. Output: The most frequent K words in the text. My thinking is like this. use a Hash table to record all words’ frequency while traverse the whole word sequence. [Read More]