- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Difference Between Quick Sort and Merge Sort
In this post, we will understand the difference between Quick Sort and Merge Sort.
Quick Sort
In Quick Sort, the elements need to be partitioned into different parts repeatedly until it can’t be divided further.
The array is split into a specific number of parts, in a specific ratio.
It is not divided necessarily into exactly half.
It is based on divide and conquer strategy.
It is also known as partition exchange sort.
The worst case complexity is O(n squared).
It uses a key/pivot element to sort elements.
It works well with small number of elements in an array.
It is better than other sorting algorithms since it is quick.
It requires less additional space/memory.
It doesn’t work well with large number of elements in an array.
It is not considered a stable sorting method.
It is considered as an internal sorting algorithm.
Merge Sort
Merge Sort is considered as an external sorting algorithm.
The array is split into two sub-arrays (n/2) where ‘n’ is the number of elements in the array.
This is done until only on element is left after splitting the array.
It is based on divide and conquer strategy.
Its worst case complexity is O(n Log n), where ‘n’ is the number of elements.
It works with any size of the array, be it small or large.
It uses additional storage, since it needs to sort the auxiliary array.
It uses three arrays, where two of them store two halves of the array and the third array stores the final sorted list.
It works well at a good speed on any data size.
It is considered to be efficient.
It is considered to be a stable sorting algorithm.
- Related Articles
- Merge sort vs quick sort in Javascript
- Quick Sort
- Difference Between Insertion Sort and Selection Sort
- Difference Between Bubble Sort and Selection Sort
- Merge Sort
- Python Program for Iterative Quick Sort
- Java Program for Iterative Quick Sort
- How to implement quick sort in JavaScript?
- Using merge sort to recursive sort an array JavaScript
- Python Program for Merge Sort
- Explain Merge Sort in Python
- Merge Sort Tree in C++
- C program to sort an array by using merge sort
- C++ Program to Implement Quick Sort Using Randomization
- C# program to perform Quick sort using Recursion
