So i found another implementation of mergesort on the internet which
was incredebly much faster and i dont even understand how it can be so
fast. I also tried printing array contents too see if it was correct
and it was. This other implementation of mergesort could sort an array
of 5million elements in only 5seconds, when i tried to sort an array
of 50 000 elements with your implementation of mergesort it took
around 7 seconds. Could you explain this? Is there something wrong
with the other implementation i found or is your code just very slow?
The other implementation i found of mergesort here:
http://www.mycstutorials.com/articles/sorting/mergesort
answers appreciated alot!
//ohman
i have found the problem, the problem is the allocation of the helper
array, it is created the size of the initial array over and over,
which made a lot of allocation and deallocation, i have moved the
helper array to also be a class variable and not set to null it each
merge and the performance of vogella's is slightly better than the
mycstutorials, the source code for my modification and test code is
available on my github
no problem