Question: In given large string, find the most occurring words in the string. What is the Time Complexity of the above solution? a. Create a Hashtable

In given large string, find the most occurring words in the string. What is the Time Complexity of the above solution?

a. Create a Hashtable which will keep track of

b. Iterate through the string and keep track of word frequency by inserting into Hash-Table.

c. When we have a new word, we will insert it into the Hashtable with frequency 1. For all repetition of the word, we will increase the frequency.

d. We can keep track of the most occurring words whenever we are increasing the frequency we can see if this is the most occurring word or not.

e. Time Complexity is O(n) where n is the number of words in the string and Space Complexity is the O(m) where m is the unique words in the string.

Step by Step Solution

3.50 Rating (160 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Data Structures Algorithms Questions!