SlideShare a Scribd company logo
3
Most read
4
Most read
5
Most read
Mergesort vs Quicksort
In Depth Analysis
Presented By
Maharaj Dey 11500117099
and
Sandeep Kumar 11500117059
Why quicksort is better than mergesort ?
This a common question asked in DS interviews
that despite of better worst case performance of
mergesort, quicksort is considered better
than mergesort.
QuickSort
Merge Sort
Basis for
comparison
Quick Sort Merge Sort
The partition of
elements in the array
The splitting of a array of elements is in any ratio, not
necessarily divided into half.
In the merge sort, the array is parted into just
2 halves (i.e. n/2).
Worst case complexity O(n2) O(nlogn)
Works well on It works well on smaller array It operates fine on any size of array
Speed of execution
It work faster than other sorting algorithms for small
data set like Selection sort etc
It has a consistent speed on any size of data
Additional storage
space requirement
Less(In-place) More(not In-place)
Efficiency Inefficient for larger arrays More efficient
Sorting method Internal External
Stability Not Stable Stable
Preferred for for Arrays for Linked Lists
Locality of reference good poor
Comparison
There are certain reasons due to which quicksort is better especially in case of arrays:
Auxiliary Space : Mergesort uses extra space,
quicksort requires little space and exhibits good
cache locality. Quick sort is an in-place sorting
algorithm. In-place sorting means no additional
storage space is needed to perform sorting. Merge
sort requires a temporary array to merge the
sorted arrays and hence it is not in-place giving
Quick sort the advantage of space.rge sort.
Locality of reference : Quicksort in
particular exhibits good cache locality and
this makes it faster than merge sort in
many cases like in virtual memory
environment.
Worst Cases : The worst case of
quicksort O(n2) can be avoided by using
randomized quicksort. It can be easily avoided
with high probability by choosing the right pivot.
Obtaining an average case behavior by choosing
right pivot element makes it improvise the
performance and becoming as efficient as
Merge sort.
Merge sort is better for large data
structures: Mergesort is a stable sort, unlike
quicksort and heapsort, and can be easily
adapted to operate on linked lists and very large
lists stored on slow-to-access media such as disk
storage or network attached storage.
Testcase Input:
25600
193 710 -326 -212 630 434 -378 728 25 702 -324
719 -546 -754 -256 -254 268 -718 -145 -28 12
125………
Program Code in Brief
Outputs Results:

More Related Content

PPT
Dinive conquer algorithm
PPTX
Merge sort and quick sort
PDF
Algorithms Lecture 4: Sorting Algorithms I
PPTX
sum of subset problem using Backtracking
PPTX
8 queen problem
PDF
Dimensionality Reduction
PPT
Data Structures- Part5 recursion
PDF
Algorithms Lecture 5: Sorting Algorithms II
Dinive conquer algorithm
Merge sort and quick sort
Algorithms Lecture 4: Sorting Algorithms I
sum of subset problem using Backtracking
8 queen problem
Dimensionality Reduction
Data Structures- Part5 recursion
Algorithms Lecture 5: Sorting Algorithms II

What's hot (20)

PPT
BackTracking Algorithm: Technique and Examples
PPTX
Greedy Algorithm - Knapsack Problem
PPTX
Asymptotic Notations
PPTX
Job sequencing with deadline
PPTX
Prim's algorithm
PPTX
Travelling salesman dynamic programming
PPTX
Merge sort
PPT
Recursion tree method
PPTX
Asymptotic Notation
PPT
Greedy Algorihm
PPT
Minimum spanning tree
PPTX
The n Queen Problem
PPTX
Merge Sort
PDF
N Queens problem
PPTX
First order predicate logic (fopl)
PPT
Algorithm analysis
PPTX
RECURSIVE DESCENT PARSING
PPTX
Artificial Intelligence Notes Unit 4
PDF
5. Linear Algebra for Machine Learning: Singular Value Decomposition and Prin...
PPTX
Chomsky classification of Language
BackTracking Algorithm: Technique and Examples
Greedy Algorithm - Knapsack Problem
Asymptotic Notations
Job sequencing with deadline
Prim's algorithm
Travelling salesman dynamic programming
Merge sort
Recursion tree method
Asymptotic Notation
Greedy Algorihm
Minimum spanning tree
The n Queen Problem
Merge Sort
N Queens problem
First order predicate logic (fopl)
Algorithm analysis
RECURSIVE DESCENT PARSING
Artificial Intelligence Notes Unit 4
5. Linear Algebra for Machine Learning: Singular Value Decomposition and Prin...
Chomsky classification of Language
Ad

Similar to Merge Sort vs Quick Sort presentation (20)

PDF
Introduction to Memoria
PPTX
slidesgo-mastering-merge-sort-efficient-sorting-techniques-for-modern-applica...
PPTX
Insertion SortInsertion SortInsertion SortInsertion Sort
PPTX
this presentation is about tim sort algorithm and tim sort algorithms is a hy...
PDF
Automated Storage Tiering
PDF
Performance Considerations in Logical Data Warehouse
PPT
Parallel and Distributed Information Retrieval System
PDF
Implementing sorting in database systems
PDF
Modified Pure Radix Sort for Large Heterogeneous Data Set
PDF
MongoDB Sharding
PDF
Performance and predictability
PPTX
merg sort slide created by anas sanan.pptx
PDF
A kind and gentle introducton to rac
PPTX
Rt databases vs general purpose tsp
PDF
Hadoop bank
PPTX
Merge Sort (w/ principle, algorithm, code, visualizations)
PPTX
Megastore by Google
PPTX
Big Data DC - Analytics at Clearspring
PDF
DISTRIBUTED AND BIG DATA STORAGE MANAGEMENT IN GRID COMPUTING
PDF
In-Memory Data Grids: Explained...
Introduction to Memoria
slidesgo-mastering-merge-sort-efficient-sorting-techniques-for-modern-applica...
Insertion SortInsertion SortInsertion SortInsertion Sort
this presentation is about tim sort algorithm and tim sort algorithms is a hy...
Automated Storage Tiering
Performance Considerations in Logical Data Warehouse
Parallel and Distributed Information Retrieval System
Implementing sorting in database systems
Modified Pure Radix Sort for Large Heterogeneous Data Set
MongoDB Sharding
Performance and predictability
merg sort slide created by anas sanan.pptx
A kind and gentle introducton to rac
Rt databases vs general purpose tsp
Hadoop bank
Merge Sort (w/ principle, algorithm, code, visualizations)
Megastore by Google
Big Data DC - Analytics at Clearspring
DISTRIBUTED AND BIG DATA STORAGE MANAGEMENT IN GRID COMPUTING
In-Memory Data Grids: Explained...
Ad

More from maharajdey (6)

PPTX
FInal Year Project Presentation
PPTX
Medern Symmetric -Key Ciphers (AES, DES)
PPTX
A* Algorithm
PPTX
Softwere Testing Aplication Specific Techniques
PPTX
Classification of Compiler
PPTX
Cloud Service Models
FInal Year Project Presentation
Medern Symmetric -Key Ciphers (AES, DES)
A* Algorithm
Softwere Testing Aplication Specific Techniques
Classification of Compiler
Cloud Service Models

Recently uploaded (20)

PPTX
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
PPT
Miokarditis (Inflamasi pada Otot Jantung)
PPTX
Introduction to machine learning and Linear Models
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PPT
ISS -ESG Data flows What is ESG and HowHow
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
Business Acumen Training GuidePresentation.pptx
PDF
Business Analytics and business intelligence.pdf
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PDF
Lecture1 pattern recognition............
PPTX
Supervised vs unsupervised machine learning algorithms
PDF
Clinical guidelines as a resource for EBP(1).pdf
PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PDF
Mega Projects Data Mega Projects Data
PDF
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
PPTX
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
PPT
Reliability_Chapter_ presentation 1221.5784
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PDF
Fluorescence-microscope_Botany_detailed content
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
Microsoft-Fabric-Unifying-Analytics-for-the-Modern-Enterprise Solution.pptx
Miokarditis (Inflamasi pada Otot Jantung)
Introduction to machine learning and Linear Models
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
ISS -ESG Data flows What is ESG and HowHow
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
Business Acumen Training GuidePresentation.pptx
Business Analytics and business intelligence.pdf
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
Lecture1 pattern recognition............
Supervised vs unsupervised machine learning algorithms
Clinical guidelines as a resource for EBP(1).pdf
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
Mega Projects Data Mega Projects Data
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
Reliability_Chapter_ presentation 1221.5784
oil_refinery_comprehensive_20250804084928 (1).pptx
Fluorescence-microscope_Botany_detailed content
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj

Merge Sort vs Quick Sort presentation

  • 1. Mergesort vs Quicksort In Depth Analysis Presented By Maharaj Dey 11500117099 and Sandeep Kumar 11500117059
  • 2. Why quicksort is better than mergesort ? This a common question asked in DS interviews that despite of better worst case performance of mergesort, quicksort is considered better than mergesort.
  • 5. Basis for comparison Quick Sort Merge Sort The partition of elements in the array The splitting of a array of elements is in any ratio, not necessarily divided into half. In the merge sort, the array is parted into just 2 halves (i.e. n/2). Worst case complexity O(n2) O(nlogn) Works well on It works well on smaller array It operates fine on any size of array Speed of execution It work faster than other sorting algorithms for small data set like Selection sort etc It has a consistent speed on any size of data Additional storage space requirement Less(In-place) More(not In-place) Efficiency Inefficient for larger arrays More efficient Sorting method Internal External Stability Not Stable Stable Preferred for for Arrays for Linked Lists Locality of reference good poor Comparison
  • 6. There are certain reasons due to which quicksort is better especially in case of arrays: Auxiliary Space : Mergesort uses extra space, quicksort requires little space and exhibits good cache locality. Quick sort is an in-place sorting algorithm. In-place sorting means no additional storage space is needed to perform sorting. Merge sort requires a temporary array to merge the sorted arrays and hence it is not in-place giving Quick sort the advantage of space.rge sort. Locality of reference : Quicksort in particular exhibits good cache locality and this makes it faster than merge sort in many cases like in virtual memory environment. Worst Cases : The worst case of quicksort O(n2) can be avoided by using randomized quicksort. It can be easily avoided with high probability by choosing the right pivot. Obtaining an average case behavior by choosing right pivot element makes it improvise the performance and becoming as efficient as Merge sort. Merge sort is better for large data structures: Mergesort is a stable sort, unlike quicksort and heapsort, and can be easily adapted to operate on linked lists and very large lists stored on slow-to-access media such as disk storage or network attached storage.
  • 7. Testcase Input: 25600 193 710 -326 -212 630 434 -378 728 25 702 -324 719 -546 -754 -256 -254 268 -718 -145 -28 12 125……… Program Code in Brief Outputs Results: