answersLogoWhite

0

Who is better quick sort or merge sort?

Updated: 8/10/2023
User Avatar

Singhumesh

Lvl 1
12y ago

Best Answer

Statistically both MergeSort and QuickSort have the same average case time: O(nlog(n)); However there are various differences.

Most implementations of Mergesort, require additional scratch space, which could bash the performance. The pros of Mergesort are: it is a stable sort, and there is no worst-case scenario.

Quicksort is often implemented inplace thus saving the performance and memory by not creating extra storage space. However the performance falls on already sorted/almost sorted lists if the pivot is not randomized.

== ==

User Avatar

Wiki User

15y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Among those three, you can automatically discard bubble sort as the worst in general cases (it actually performs quite well when the list of numbers are already in order, unlike quick sort).

In general, merge sort is O(n log n) and quick sort is O(n log n). The two main differences are that 1) quick sort can have a degradation in performance if the pivot point is chosen poorly (O(n2)), 2) quick sort does not require the extra storage that merge sort does.

While I'm not an algorithms expert, I do know that most people tend to err on the side of using quick sort. I have never actually seen anyone implement a merge sort when they had a choice.

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

merge sort is a stable sort, parallelizes better, and is more efficient at handling slow-to-access sequential media. Merge sort is often the best choice for sorting a linked list: in this situation it is relatively easy to implement a merge sort in such a way that it requires only Θ(1) extra space, and the slow random-access performance of a linked list makes some other algorithms (such as quicksort) perform poorly, and others (such as heapsort) completely impossible.

see related links.

This answer is:
User Avatar

User Avatar

Wiki User

8y ago

There is no single answer. The reason we have so many sorting algorithms is because there is no one algorithm that meets the needs of every application. For instance, the QuickSort algorithm is capable of sorting large data sets with reasonable efficiency, but it is unstable (stable versions exist at the cost of performance) and is not suitable for sorting disk-based data (data that is too large to fit into memory all at once). Merge Sort is stable and can handle disk-based data more efficiently, but for memory-based data, a QuickSort will generally be faster. By contrast, Insert Sort and Selection Sort are much better suited to sorting small data sets.

Hybrid sorts (a combination of two or more algorithms) are more generalised algorithms, providing a reasonable compromise between speed, stability and efficiency. For instance, a stable version of QuickSort can be used to divide the set into smaller and smaller partitions until a partition is small enough to be handled by an Insertion Sort. Intro Sort is an example of a hybrid algorithm.

It should be noted that Bubble Sort has no practical applications whatsoever. It is often cited as an example of how not to write an algorithm. However, a single-pass Bubble Sort is an efficient means of determining if a set is already sorted (immediately terminating if any pair of elements are in the wrong order). By definition, a sorting algorithm that does not actually sort anything cannot be regarded as being a sorting algorithm.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

quick sort doesn't require extra storage than merge sort dose

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

quick sort is better,bcoz it doesn't take extra space of memory...

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

quick sort

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Who is better quick sort or merge sort?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering
Related questions

Why quick sort better than merge sort?

it has less complexity


Limitations of merge sort and quick sort?

Comolexity Not efficent big data


Different types of sorting techniques in c language?

types of sorting in c language are: insertion sort selection sort bubble sort merge sort two way merge sort heap sort quick sort


What are the types of sort algorithms?

insertion,bubble,quick, quick3, merge, shell,heap, selection sorting


When would you use bubble sort?

Never. Bubble sort is often cited as an example of how not to write a sorting algorithm and is used purely as a programming exercise. It is never used in production code. Although reasonably efficient when sorting small lists, an insertion sort performs better on average. But for larger lists it has no practical uses. A merge sort is better for large lists, but if stability isn't an issue a quick sort is even better. Hybrid sorts typically use quick sort until a partition is small enough for an insertion sort to complete the job.


Which key element will be best for merge sort and why?

There is no key element in a merge sort. Unlike quick sort which requires a key element (a pivot) to recursively divide a subset into two subsets, merge sort simply divides a subset into subsets of 1 element and merges adjacent subsets together to produce sorted subsets. When there is only one subset remaining, the subset is fully sorted.


If quick sort and merge sort have same elements then what will be the complexity of both algorithms?

quicksort should be O(n^2), but merge sort should be O(nlogn). but if you can modify partition algorithm with checking all values same in array from p to r, it could be O(nlogn).


When does quick sort take more time than merg sort?

Quick sort runs the loop from the start to the end everytime it finds a large value or a small value while in merge sort starts from the first position of the array and assembles the large or small numbers in one side in just one loop so its more faster than quick sort


Who is best merge sort or insertion sort?

Merge sort is good for large data sets, while insertion sort is good for small data sets.


Whose sorting is best amongst sorting techniques?

The reason we have so many sorting techniques is that there is no "best." Depending on circumstances, your best bet will usually be either quick sort or merge sort.


When is quick sort better than selection sort?

Because the quick sort can be used for large lists but selection not. selection sort is used to find the minimum element ,but quick choose element called pivot and move all smaller nums before it & larger after it.


What is the difference between shell sort and merge sort?

shell uses an odd number,merge uses an even number?