Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

Best sorting algorithm??? C++


ghost's Avatar
0 0

Recently i've came across a project that ask me to count every single word's frequency in a book….

which is very easy… but I want to make most efficient and fast as possible….

I've utilized BST and as many pointer as i could so I would use less memory…

problem is… sorting….

what would be the best sorting algorithm here???

my choice was heap sorting, because it uses Big O (1) memory and still Big O of n log n speed…. which is quite good…

any other ideas??

I think i could use some better sorting algorithms that i don't know about…

P.S. book i've use to test was King Jame version of Bible and my program was able to read, process 12803 different words, +60000 total words, and sort data in less then about avg of 4 sec with a computer from lab with a gig of ram… is that good???


ghost's Avatar
0 0

60000 words = about 600 kb

4 secs is decent


ynori7's Avatar
Future Emperor of Earth
0 0

the quick sort and the merge sort are good, but they're a bit difficult to code.

i personally like the insertion sort. it's about average in speed, but it's very simple.


ghost's Avatar
0 0

ynori7 wrote: the quick sort and the merge sort are good, but they're a bit difficult to code.

i personally like the insertion sort. it's about average in speed, but it's very simple.

really?? I considered it easy to code…

didn't use merge and quick sort because it uses more memory then heap sort… which is O(1)….

and insertion sort isn't any where near the speed of heap sort when you are dealing with big numbers of datas like bible….


ghost's Avatar
0 0

Try one called clasitext (named casitex in some sources). Part of this algorithm count the frecuency of every single word in the text. The other part is for clasification of the meaning of the words. I think it be useful to you, trying the first part of this algorithm (the count of the frecuency one). I hope this information would be helpful for you.