0

If I have a big array with a high range of values, which would be faster, Quick sort or Merge sort?

First I would say both take the same time, because both have best case O(n*log(n) and both sorting algorithms should not be negatively effected by the array specification.

But because Quick sort is very reliant on the pivot you might want to argue that merge is better

Alex Riley
  • 169,130
  • 45
  • 262
  • 238
  • possible duplicate of [Why is quicksort better than mergesort?](http://stackoverflow.com/questions/70402/why-is-quicksort-better-than-mergesort) – honk Apr 06 '15 at 16:49

1 Answers1

0

From the theoretical point of view, there should be no big difference:

  • quicksort has an expected complexity of O(n log n) for random choice of the pivot element, but in worst case it could be up to O(n²).
  • mergesort has a fixed complexity of O(n log n)

I know that a professor of mine and his work group is sorting big sets of data (> 100 GB) using mergesort. He says that mergesort can be modified to reduce the number of read/write operation on your hard disc. Since they are very slow compared to read/write operations on your RAM, they are, what slows the algorithm massively down.

AbcAeffchen
  • 14,400
  • 15
  • 47
  • 66