Mergesort

Merge sort is an O(n log n) worst-case comparison-based stable sorting algorithm.

Quicksort

Quicksort is a sorting algorithm invented by C



Simpler in-place parallelizing

Example

"Previously discussed on so why is quicksort better than mergesort"

from question  

Quicksort slower than Mergesort?

"Is quicksort always better than mergesort"

from question  

Why is quicksort better than mergesort?

"I ve looked at the question at why is quicksort better than mergesort"

from question  

Quicksort vs Mergesort in terms of comparisons

"Why is quicksort better than mergesort"

from question  

Is Quicksort a potential security risk?

"I generally recommend starting with bottom-up mergesort in haskell but heapsort isn t a bad choice either;quicksort poses much more serious difficulties"

from question  

Sort algorithm for list of integers in Haskell with recursion

"See multithreaded quicksort or mergesort it is easier to pass several parameters to a thread using a control struct"

from question  

Merge Sort with PThreads in C

"Quicksort and heapsort are both normally considered in-place and heapsort can be implemented with o 1 extra space i was mistaken about this earlier;mergesort is more difficult to implement in-place but the out-of-place version is very cache-friendly - i suspect real-world implementations accept the o n space overhead - ram is cheap but memory bandwidth is a major bottleneck so trading memory for cache-efficiency and speed is often a good deal"

from question  

Sorting in place

"Quicksort is not better than mergesort"

from question  

Why is quicksort better than mergesort?

"Quicksort usually is better than mergesort for two reasons"

from question  

When merge sort is preferred over Quick sort?

"I would say that the quicksort is simpler for parallelizing than the mergesort"

from question  

Sorting a linked list in parallel using Insertion Sort

"Parallelizing mergesort is simpler than quicksort in-place"

from question  

When to use merge sort and when to use quick sort?

Worst comparisons complexity

Example

"Mergesort may use more space than quicksort i m not entirely sure and merge may be better for linkedlists"

from question  

When to use sorts over another

"For instance quicksort can outperform mergesort although mergesort is provably better than quicksort in the worst case"

from question  

Non-deterministic polynomial solutions over deterministic polynomial solution

"For example locality of references has influence on cache hits or misses which is the reason why quicksort performs better than mergesort"

from question  

Big O(n logn) is not preferable over the O(n^2)

"I know mergesort is better since it is stable and doesn t have n 2 as worst case but i required to implement quicksort"

from question  

Implementation of Quick Sort for ArrayList of Object using Comparator

"An interesting answer about this can be found at why is quicksort better than mergesort"

from question  

A basic confusion on quicksort

"Technically mergesort has a better time-behavior î nlogn worst and average cases than quicksort î n 2 worst case î nlogn average case"

from question  

QuickSort vs MergeSort, what am I doing wrong?

"Quicksort is not better it is well suited for a different kind of application than mergesort"

from question  

Why is quicksort better than mergesort?

"Mergesort uses about 30 less comparisons than quicksort"

from question  

When merge sort is preferred over Quick sort?

"Given that it is possible to vastly reduce the likelihood of the worst case of quicksort s time complexity via random selection of the pivot for example i think one could argue that mergesort is worse in all but the pathological case of quicksort"

from question  

Worse is better. Is there an example?

"Interestingly quicksort performs more comparisons on average than mergesort - 1.44 n lg n expected for quicksort versus n lg n for mergesort"

from question  

Why is quicksort used in practice?

"Under one plausible definition of average case quicksort is expected to do about 40 more comparisons than mergesort"

from question  

Are my sort algorithms correct? Why does merge sort take fewer iterations than quick sort?

"Quicksort is worse complexity than mergesort in the worst case."

from question  

Efficient traversal of a changelist

"Purely in terms of the number of comparisons performed is mergesort always more efficient than quicksort"

from question  

Quicksort vs Mergesort in terms of comparisons

Faster algorithm slower

Example

"That way quicksort can reach recursive base case more quicker than mergesort"

from question  

Why is quicksort better than mergesort?

"I have read that quicksort is much faster than mergesort in practise and the reason for this is the hidden constant"

from question  

Exactly how many comparisons does merge sort make?

"Quicksort generally runs faster than mergesort but under some circumstances mergesort can degrade to quadratic running time"

from question  

Efficient Sorting?

"Quicksort has better locality of reference than mergesort which means that the accesses performed in quicksort are usually faster than the corresponding accesses in mergesort"

from question  

When merge sort is preferred over Quick sort?

"Quicksort consistently has less recursive calls than mergesort"

from question  

Why is quicksort better than mergesort?

"Depending on where i look people say quicksort is faster than mergesort due to its locality of reference cache hits etc"

from question  

Quicksort vs Mergesort in terms of comparisons

"Quicksort is usually faster than mergesort just because it s easier to code a tight implementation and the operations it does can go faster"

from question  

Why is quicksort better than mergesort?

"In most cases quicksort will run faster than mergesort even though the worst-case execution time is longer"

from question  

Which sorting algorithm is used in stl and .net base library default search?

"To be specific the quicksort runs faster than mergesort in the first test case and loses badly in the following 9 tests"

from question  

Comparison of Mergesort & Quicksort with Linked List

"From what i ve read i was expecting quicksort to be faster than mergesort but on my code it is not so i assume there must be a problem with my quicksort algorithm"

from question  

QuickSort vs MergeSort, what am I doing wrong?

"Quicksort is approximately 40 faster than mergesort on random data because of fewer data movements"

from question  

QuickSort vs MergeSort on arrays of primitives in Java

"Normally quicksort is faster than mergesort which is faster than heapsort"

from question  

How do different languages implement sorting in their standard libraries?

"You can also see that for smaller collections quicksort is faster but then mergesort takes the lead but all of this is case specific so take your time to study all 4 algorithms"

from question  

Sorting in O(n*log(n)) worst case

"For the 10 tests on the same list the results should be quite the same at least all showing that quicksort is faster than mergesort or vice vesa"

from question  

Comparison of Mergesort & Quicksort with Linked List

"Quicksort is implemented well it is typically 2-3 times faster than mergesort or"

from question  

Why is quicksort faster in average than others?

"As many people have noted the average case performance for quicksort is faster than mergesort"

from question  

Why is quicksort better than mergesort?

"It might be helpful to see why quicksort is usually faster than mergesort since if you understand the reasons you can pretty quickly find some cases where mergesort is a clear winner"

from question  

When merge sort is preferred over Quick sort?

"Insertion sort for example has an average time-complexity of o n 2 worse than quicksort or mergesort but as an online algorithm it can efficiently sort a list of values as it are received as user input where most other algorithms can only efficiently operate on a complete list of values"

from question  

Are there any cases where you would prefer a higher big-O time complexity algorithm over the lower one?

"Scenarios when quicksort is worse than mergesort"

from question  

When merge sort is preferred over Quick sort?

"I have been testing the practicality of openmp gnu parallel sort algorithms in the c++ standard library and have found the parallel quicksort algorithm to be significantly slower than the mergesort algorithm"

from question  

Why is GNU parallel Quicksort so slow compared to Mergesort?

"However on smaller int sizes quicksort gets slower and mergesort gets faster"

from question  

Hand-coded quicksort is slower on smaller integers

"When comparison function is a callback function like in quicksort libc implementation quicksort is slower than mergesort by 15 on random input and 30 for already sorted array for 64 bit integers"

from question  

Why is quicksort better than mergesort?

"However at least quicksort is not slower than mergesort for the random case"

from question  

Why does Haskell use mergesort instead of quicksort?

"It s not a question of is map reduce better than mergesort or quicksort because map reduce is just a tool for implementing a sorting algorithm like mergesort or quicksort in a parallel way"

from question  

Sort Using Map and Reduce Techinques

"Quicksort is fast when the data fits into memory and can be addressed directly;mergesort is faster when data won t fit into memory or when it s expensive to get to an item"

from question  

Why is merge sort preferred over quick sort for sorting linked lists

"The results were as follows data.list.sort 0.171s mergesort 1.092s 6x slower than data.list.sort quicksort 1.152s 7x slower than data.list.sort"

from question  

Why does Haskell use mergesort instead of quicksort?

"Quicksort s because quicksort is generally faster that people use quicksort instead of mergesort"

from question  

Why is quicksort better than mergesort?

"When comparing my quicksort implementation with std sort on my compiler and my implementation of mergesort i noticed an odd pattern on large data sets when operating on 64 bit integers quicksort is consistently faster than mergesort"

from question  

Hand-coded quicksort is slower on smaller integers

"Mergesort is slightly slower than quicksort but it does not have quicksort s susceptibility to pathological cases"

from question  

Manually sorting vector<int> in C++

"Quicksort is a partitioning sorting algorithm you might refer to mergesort which also is a partitioning sorting algorithm the biggest difference is probably the speed quicksort is faster even though both of the biggest difference are o n log n"

from question  

What is the difference between partition sort and quick sort?

"Quicksorta performs marginally better than mergesort for large datasets on my system but performance will depend on the actual implementation of quicksort which does not necessarily use a quicksort algorithm"

from question  

Is sorting a Linked List using Quicksort really slower than Mergesort because of no random access in Linked List?

"Quicksort this is a bit tricky to implement efficiently with lists but it is possible;i won t discuss it because it s not a good early programming project and mergesort is faster in many cases"

from question  

How do i make a link list print out its contents in alphabetical order?

"The quicksort algorithm is faster than mergesort which is what sorted will get you when called on a sequence of objects via java.util.arrays.sort"

from question  

How to sort lines on a value in them

"Mergesort - in general mergesort is consistently faster than quicksort however quicksort is done in place and doesn t require allocating memory unlike mergesort"

from question  

Is it sometimes better to write solution in O(n^2) than in O(n)?

Others

Example

Also note that quicksort is generally more optimal than mergesort see this as well which explains why it s taken advantage of when sorting primitives

from question  

Arrays.sort() -- two different strategies for primitive & complex data types to be sorted

Quicksort is also more complicated than mergesort especially if you want to write a really solid implementation and so if you re aiming for simplicity and maintainability merge sort becomes a promising alternative with very little performance loss

from question  

Quick Sort Vs Merge Sort

Quicksort generally performs better and takes less memory but many examples have worst-case performance of o n 2 which almost never occurs in practice;mergesort doesn t perform quite as well but is usually implemented to be stable and mergesort s easy to do part in memory and part on disk that is use the built-in sort function

from question  

Radix sort for strings of arbitrary lengths

This means that while the two underlying sorts it uses mergesort and insertion sort are both worse than quicksort for many kinds of data timsort only uses them when it is advantageous to do so

from question  

Comparison between timsort and quicksort

Quicksort is more sensitive to input sortedness in a positive way than mergesort

from question  

Why does order of mergesort and quicksort operations cause the second operation to run faster?

For instance quicksort does not have a tight bound unless we are talking specifically about either best average or worst case analysis as it s ω nlogn in the best and average cases but o n 2 in the worst case;on the other hand mergesort is both ω nlogn and o nlogn therefore it s also θ nlogn

from question  

Algorithm Analysis - Asymptotic analysis

But remember mergesort is not in place mergesort require 2n memeroy space.and mergesort also need to do many array copies which we don t include in the analysis of algorithm.in a word mergesort is really faseter than quicksort in theroy but in reality you need to consider memeory space the cost of array copy merger is slower than quick sort.i once made an experiment where i was given 1000000 digits in java by random class and it took 2610ms by mergesort 1370ms by quicksort

from question  

Why is quicksort better than mergesort?

Hat you do not need a second array to store like mergesort you do not need a second array to store like mergesort is calculated inside the same memory;what does author mean by quicksort has a shorter inner loop than most

from question  

Quick sort analysis and behaviour

Quicksort is slow for lists mergesort is not in-place for arrays;short answer quicksort is advantageous for arrays in-place fast but not worst-case optimal

from question  

Why does Haskell use mergesort instead of quicksort?

Mergesort is more natural to implement for linked lists but you can do quicksort very nicely

from question  

Optimal Quicksort for Single Linked List

That s hard to say.the worst of mergesort is n log2n -n+1 which is accurate if n equals 2 k i have already proved this .and for any n it s between n lg n - n + 1 and n lg n + n + o lg n .but for quicksort its best is nlog2n also n equals 2 k .if you divide mergesort by quicksort it equals one when n is infinite.so it s as if the worst case of mergesort is better than the best case of quicksort why do we use quicksort

from question  

Why is quicksort better than mergesort?

The biggest difference that can be produced between the two of them will always be to quicksort s detriment and it involves lists that are already largely sorted or contain a large number of ties when quicksort does better than mergesort the difference will not be nearly so great

from question  

Quicksort slower than Mergesort?

Note this may reduce memory usage if you have a really large dataset it is actually used to handle such situations but may perform worse than raw quicksort beacause of the split cost which becomes linear if you copy over the subarrays and the multithreading overhead;consider that inplace mergesort is more space-efficient when applied to large arrays

from question  

Concurrent sorting in Java

There are numerous problems with this question starting with the fact that you ve implemented a very slow version of quicksort but asked a question about mergesort;mergesort is not typically implemented as a tail recursive algorithm

from question  

How do I turn a recursive algorithm into a tail-recursive algorithm?

Your implementation may of course have stack unwinding while in mergesort the sorting is done on the way up the splitting step does not move elements at all but on the way back up you need to merge two sorted lists;as for the performance comparisons it is certainly true that the worst-case behavior of quicksort is worse than that of mergsesort but the constant factor for the average case which is observed almost exclusively in practice is smaller which makes quicksort usually the winner for generic unsorted input

from question  

What's the difference between quicksort and mergesort?

A good example of this is quicksort versus mergesort;they both have an average runtime of o n log n but quicksort is usually faster

from question  

Complexity in Algorithms

Quicksort cannot be used on lists;for lists mergesort is the way to go as long as the list contains more than one element split it into two lists sort each of them then merge the two sorted lists into one since both lists are sorted only the heads have to be compared

from question  

C programming sorting an array of structs based on 4 strings

Therefore quicksort is not an option;so a variant of mergesort is used the current java versions use timsort

from question  

Why does Collections.sort use Mergesort but Arrays.sort does not?

Quicksort has less overhead so with small n and slow computers it is better;but computers are so fast today that the additional overhead of a mergesort is negligible and the risk of a very slow quicksort far outweighs the insignificant overhead of a mergesort in most cases

from question  

Why is quicksort better than mergesort?

As a result for relatively small datasets quicksort is more likely to get cache hits and therefore just tends to run faster on most hardware;mergesort is still a pretty good solution for large data sets or other data structures like linked lists as your experiments confirm

from question  

Quicksort slower than Mergesort?

I do know though that quicksort has more compares but less swaps than mergesort which i learned from another stackoverflow discussion quicksort vs merge sort

from question  

* (no title is found for this review)

I had been taught that quicksort is almost always quicker than mergesort and i understand that there is some debate on this topic but i at least expected it to be closer than this

from question  

Quicksort slower than Mergesort?

Quicksort is faster than mergesort because it has no loop in it s recursion where mergesort has to copy it s element in aux array and one more thing o nlogn is number of compares that mergesort does but it does also 6nlogn array acceses

from question  

Which sorting algorithm is better?

Back to Home
Data comes from Stack Exchange with CC-BY-SA-4.0