Suppose we have a document of D distinct words and we want to return the N most frequently occuring words in the document. Assume N is much less than D. Describe the fastest algorithm (clearly list each step of the algorithm) to solve this problem, starting with a hash table in which to store the frequencies. You may use additional structures, as long as they are one of the structures covered in class. Make sure to specify what is the key and what is the value for all structures used. Against each step of your algorithm, write down the big 0 running time with an explanation of how you got it, and specify whether this running time is expected time or worst case time. You can use known-from-class structures you use, **but you still have to write what the actual running time is**
Using java
Suppose we have a document of D distinct words and we want to return the N most frequently occuring words in the document. Assume N is much less than D.
Describe the fastest
Against each step of your algorithm, write down the big 0 running time with an explanation of how you got it, and specify whether this running time is expected time or worst case time. You can use known-from-class structures you use, **but you still have to write what the actual running time is**
using java best way effective algorithm to find the most frequently word is using HashMap data structure, whose insertion and deletion time complexity is O(1) and the wrost case time complexity is O(N).
Hash_Map:
Hash_Map<K, V> is a piece of Java's assortment since Java 1.2.
This class is found in java.util bundle.
It gives the essential execution of the Map interface of Java.
It stores the information in (Key, Value) sets, and you can get to them by a list of another sort. example : Integer
One item is utilized as a key (file) to another article. In the event that you attempt to embed the copy key, it will supplant the component of the relating key.
Hash_Map is like the Hash_Table, however it is un-synchronized. It permits to store the invalid keys also, yet there should be just a single invalid key article and there can be quite a few invalid qualities. This class makes no certifications concerning the request for the guide.
Step by step
Solved in 3 steps