I think , as juver++ said , you should also try reading on the internet about these kinds of problems .This can be solved with an augmentation of a trie (keeping a count variable at the leaf ( maintaining a counter for all the word frequencies accordingly )) .Just print the top ten results in the end .time complexity will be O(n , log n ) .We can improve upon this solution a lot using other forms of tries and some augmentation
PS:This will take some time if we do it for n characters , but since you explicitly asked for 10 characters , so be it ! For your second question , try seraching "globbing" (For the masochists , download the source code for glob library and go through the code ) -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
