top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Sort Word based on it's occurences

0 votes
354 views

There are several words in a file. Get the occurrence of every word and sort it based on the occurrence, if more than one word is having same occurrence than sort it alphabetically.

Is there any approach better than HashMap??

HashMap Approach
1) Collect all different words in HashMap
2) If any word repeats increase it's count.
3) Now sort base on count
4) Sort words within same count.

posted Sep 11, 2014 by Atiqur Rahman

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes

By Using External Sorting method with HashMap procedure is best approach to sort words in a file.

answer Sep 23, 2014 by Aarti Jain
Similar Questions
+2 votes
+1 vote

if input this Data size 10000,100000,1000000

+3 votes

1) Implement both algorithms
2) Test both on three cases of data:
a) sorted in increase order,
b) sorted in decrease order,
c) randomly
3) Use data of different sizes: 10000, 100000, 1000000.

...