You need to design a system to find the top 10 most frequent words in a very large text corpus. Which data structures and algorithms would you use to ensure efficiency in both space and time?

  • A) Array and Selection Sort
  • B) Hash Map and Quick Sort
  • C) Trie and Merge Sort
  • D) Priority Queue (Heap) and Trie
To efficiently find the top 10 most frequent words, you should use a Priority Queue (Heap) to keep track of the top frequencies and a Trie or Hash Map to count word occurrences. A Trie can be used to efficiently store and retrieve words, while a Priority Queue helps maintain the top frequencies. The other options are less efficient in terms of both time and space complexity.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *