SlideShare a Scribd company logo
Algorithm - Mergesort & Quicksort
Course title : Algorithm - Mergesort & Quicksort
CSE-225
• Submitted By: • Submitted
ToName: Istiaque Ahmed Shuvo
Id:141311057
5th batch ,5th semester
Sec-B
Dept. Of Cse
Varendra University,rajshahi
Name: Atiquer Rahman Sarkar,
CSE,
Varendra University
Quick
sort
Algorithm
Merge sort Algorithm
Merge Sort
Merge sort is based on Divide
and conquer method. It takes
the list to be sorted and divide
it in half to create two unsorted
lists. The two unsorted lists are
then sorted and merged to get
a sorted list. The two unsorted
lists are sorted by continually
calling the merge-sort algorithm;
we eventually get a list of size 1
which is already sorted. The two
lists of size 1 are then merged.
Example sort Example
The most well known algorithm design strategy:
1.Divide instance of problem into two or
more smaller instances
2.Solve smaller instances recursively
3.Obtain solution to original (larger)
instance by combining these solutions
Divide-and-conquer
Technique
subproblem 2
of size n/2
subproblem 1
of size n/2
a solution to
subproblem 1
a solution to
the original problem
a solution to
subproblem 2
a problem of size n
Divide and Conquer
Examples
• Sorting: mergesort and quicksort
• Tree traversals
• Matrix multiplication-Strassen’s
algorithm
• Closest pair problem
Merge Sort Algorithm
MergeSort (Example) - 1
MergeSort (Example) - 2
MergeSort (Example) - 3
MergeSort (Example) - 4
MergeSort (Example) - 5
MergeSort (Example) - 6
MergeSort (Example) - 7
MergeSort (Example) - 8
MergeSort (Example) - 9
MergeSort (Example) - 10
MergeSort (Example) - 11
MergeSort (Example) - 12
MergeSort (Example) - 13
MergeSort (Example) - 14
MergeSort (Example) - 15
MergeSort (Example) - 16
MergeSort (Example) - 17
MergeSort (Example) - 18
MergeSort (Example) - 19
MergeSort (Example) - 20
MergeSort (Example) - 21
MergeSort (Example) - 22
14 23 45 98 6 33 42 67
Merge
23 45 98 33 42 6714 6
Merge
23 45 98 6 42 67
6
14 33
Merge
14 45 98 6 42 67
6 14
23 33
Merge
14 23 98 6 42 67
6 14 23
45 33
Merge
14 23 98 6 33 67
6 14 23 33
45 42
Merge
14 23 98 6 33 42
6 14 23 33 42
45 67
Merge
14 23 45 6 33 42
6 14 23 33 42 45
98 67
Merge
14 23 45 98 6 33 42 67
6 14 23 33 42 45 67
Merge
14 23 45 98 6 33 42 67
6 14 23 33 42 45 67 98
Quick
sort
Algorithm
QUICKSORT (A, p, r)
1. if p < r
2. q = PARTITION (A, p, r)
3. QUICKSORT (A, p, q-1)
4. QUICKSORT (A, q -1, r)
Partitioning the array
PARTITION (A, p, r)
1. X=A[r]
2. i =p -1
3. for j = p to r -1
4. if A[j] X
5. i = i + 1
6. exchange A[i] with A[j]
7. exchange A[i+1] with A[r]
8. return i+1
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort

More Related Content

PPTX
Merge sort and quick sort
Shakila Mahjabin
 
PPTX
Data Structure and Algorithms Merge Sort
ManishPrajapati78
 
PPT
Quick sort Algorithm Discussion And Analysis
SNJ Chaudhary
 
PPT
Algorithm: Quick-Sort
Tareq Hasan
 
PPT
Presentation on binary search, quick sort, merge sort and problems
Sumita Das
 
PPTX
Divide and conquer - Quick sort
Madhu Bala
 
PPT
3.8 quicksort
Krish_ver2
 
PPTX
Analysis of Algorithm (Bubblesort and Quicksort)
Flynce Miguel
 
Merge sort and quick sort
Shakila Mahjabin
 
Data Structure and Algorithms Merge Sort
ManishPrajapati78
 
Quick sort Algorithm Discussion And Analysis
SNJ Chaudhary
 
Algorithm: Quick-Sort
Tareq Hasan
 
Presentation on binary search, quick sort, merge sort and problems
Sumita Das
 
Divide and conquer - Quick sort
Madhu Bala
 
3.8 quicksort
Krish_ver2
 
Analysis of Algorithm (Bubblesort and Quicksort)
Flynce Miguel
 

What's hot (20)

PPT
Quicksort
Gayathri Gaayu
 
PPT
3.8 quick sort
Krish_ver2
 
PDF
Quick sort algorithn
Kumar
 
PPTX
Merge sort
Kumar
 
PPT
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
Sahil Kumar
 
PPTX
Quick sort
AreenGaur
 
PDF
Prim algorithm
University of Potsdam
 
PDF
Quicksort analysis
Premjeet Roy
 
PPT
Lec34
Nikhil Chilwant
 
PPT
03 dc
Hira Gul
 
PPT
Lec36
Nikhil Chilwant
 
PDF
Grovers Algorithm
CaseyHaaland
 
PPTX
Quick sort
amar kakde
 
PDF
signal and system Hw2 solution
iqbal ahmad
 
PPT
Insertion sort
Delowar Hossain
 
PDF
SVM (Support Vector Machine & Kernel)
SEMINARGROOT
 
PPT
Lec35
Nikhil Chilwant
 
PDF
Hw1 solution
iqbal ahmad
 
PPT
Lec33
Nikhil Chilwant
 
PPT
Inverse laplace transforms
EngrAbdullahMohamedS
 
Quicksort
Gayathri Gaayu
 
3.8 quick sort
Krish_ver2
 
Quick sort algorithn
Kumar
 
Merge sort
Kumar
 
ADA - Minimum Spanning Tree Prim Kruskal and Dijkstra
Sahil Kumar
 
Quick sort
AreenGaur
 
Prim algorithm
University of Potsdam
 
Quicksort analysis
Premjeet Roy
 
03 dc
Hira Gul
 
Grovers Algorithm
CaseyHaaland
 
Quick sort
amar kakde
 
signal and system Hw2 solution
iqbal ahmad
 
Insertion sort
Delowar Hossain
 
SVM (Support Vector Machine & Kernel)
SEMINARGROOT
 
Hw1 solution
iqbal ahmad
 
Inverse laplace transforms
EngrAbdullahMohamedS
 
Ad

Viewers also liked (8)

PPT
Computer notes - Mergesort
ecomputernotes
 
PPTX
Mergesort
Melver May Morales
 
PPTX
PPT Image Analysis(IRDE, DRDO)
Nidhi Gopal
 
PPT
3.9 external sorting
Krish_ver2
 
PPTX
Sorting algorithms
Eleonora Ciceri
 
PPTX
Introduction to wavelet transform
Raj Endiran
 
PDF
Fast Fourier Transform
op205
 
PDF
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
SlideShare
 
Computer notes - Mergesort
ecomputernotes
 
PPT Image Analysis(IRDE, DRDO)
Nidhi Gopal
 
3.9 external sorting
Krish_ver2
 
Sorting algorithms
Eleonora Ciceri
 
Introduction to wavelet transform
Raj Endiran
 
Fast Fourier Transform
op205
 
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
SlideShare
 
Ad

Similar to Algorithm - Mergesort & Quicksort (20)

PPTX
Sortings .pptx
MuhammadSheraz836877
 
PPTX
Weak 11-12 Sorting update.pptxbhjiiuuuuu
baloch4551701
 
PPTX
Quick Sort in data structure.pptx
ujjwalmatoliya
 
PPT
Sorting algos > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
PDF
Heap, quick and merge sort
Dr. Mohammad Amir Khusru Akhtar (Ph.D)
 
PPTX
DSA- Merge Sort-a sorting technique.pptx
HimangshuOfficial
 
PPTX
quick and merge.pptx
LakshayYadav46
 
PPT
MergesortQuickSort.ppt
AliAhmad38278
 
PPT
presentation_mergesortquicksort_1458716068_193111.ppt
ajiths82
 
PDF
Algorithms lecture 3
Mimi Haque
 
PPT
Quick Sort
Soumen Santra
 
PPTX
Data Structure Marge sort Group 5 pptx so
Salma368452
 
PPT
Unit 7 sorting
kalyanineve
 
PDF
Quick Sort , Merge Sort , Heap Sort
Mohammed Hussein
 
PPTX
09 QUICK SORT Design and Analysis of algorithms
syamalamaganti
 
PPT
Data Structure Sorting
Muhazzab Chouhadry
 
PPTX
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptx
LakshmiSamivel
 
PPT
Insert Sort & Merge Sort Using C Programming
chandankumar364348
 
Sortings .pptx
MuhammadSheraz836877
 
Weak 11-12 Sorting update.pptxbhjiiuuuuu
baloch4551701
 
Quick Sort in data structure.pptx
ujjwalmatoliya
 
Sorting algos > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 
Heap, quick and merge sort
Dr. Mohammad Amir Khusru Akhtar (Ph.D)
 
DSA- Merge Sort-a sorting technique.pptx
HimangshuOfficial
 
quick and merge.pptx
LakshayYadav46
 
MergesortQuickSort.ppt
AliAhmad38278
 
presentation_mergesortquicksort_1458716068_193111.ppt
ajiths82
 
Algorithms lecture 3
Mimi Haque
 
Quick Sort
Soumen Santra
 
Data Structure Marge sort Group 5 pptx so
Salma368452
 
Unit 7 sorting
kalyanineve
 
Quick Sort , Merge Sort , Heap Sort
Mohammed Hussein
 
09 QUICK SORT Design and Analysis of algorithms
syamalamaganti
 
Data Structure Sorting
Muhazzab Chouhadry
 
DIVIDE AND CONQUERMETHOD IN DATASTRUCTURE.pptx
LakshmiSamivel
 
Insert Sort & Merge Sort Using C Programming
chandankumar364348
 

More from Varendra University Rajshahi-bangladesh (13)

PPTX
Computer Graphics Presentation
Varendra University Rajshahi-bangladesh
 
PPTX
Numerical method (curve fitting)
Varendra University Rajshahi-bangladesh
 
PPTX
project for web based game
Varendra University Rajshahi-bangladesh
 
PPTX
project for web based game
Varendra University Rajshahi-bangladesh
 
DOCX
Situation of women in bangladesh
Varendra University Rajshahi-bangladesh
 
PPTX
Political culture of bangladesh
Varendra University Rajshahi-bangladesh
 
PPTX
software project management
Varendra University Rajshahi-bangladesh
 
PPTX
software project management
Varendra University Rajshahi-bangladesh
 
PPT
Javapackages 4th semester
Varendra University Rajshahi-bangladesh
 

Recently uploaded (20)

PDF
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
PDF
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
PPTX
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
PPTX
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
PPTX
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
PPTX
Congenital Hypothyroidism pptx
AneetaSharma15
 
PDF
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
PPTX
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
PDF
Landforms and landscapes data surprise preview
jpinnuck
 
PPTX
Cardiovascular Pharmacology for pharmacy students.pptx
TumwineRobert
 
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Mithil Fal Desai
 
PPTX
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PDF
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
PPTX
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
PDF
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
PDF
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
MariellaTBesana
 
PPTX
Understanding operators in c language.pptx
auteharshil95
 
DOCX
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
PPTX
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
PPTX
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 
Arihant Class 10 All in One Maths full pdf
sajal kumar
 
3.The-Rise-of-the-Marathas.pdfppt/pdf/8th class social science Exploring Soci...
Sandeep Swamy
 
Dakar Framework Education For All- 2000(Act)
santoshmohalik1
 
Odoo 18 Sales_ Managing Quotation Validity
Celine George
 
How to Manage Leads in Odoo 18 CRM - Odoo Slides
Celine George
 
Congenital Hypothyroidism pptx
AneetaSharma15
 
1.Natural-Resources-and-Their-Use.ppt pdf /8th class social science Exploring...
Sandeep Swamy
 
An introduction to Dialogue writing.pptx
drsiddhantnagine
 
Landforms and landscapes data surprise preview
jpinnuck
 
Cardiovascular Pharmacology for pharmacy students.pptx
TumwineRobert
 
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
Mithil Fal Desai
 
Information Texts_Infographic on Forgetting Curve.pptx
Tata Sevilla
 
PG-BPSDMP 2 TAHUN 2025PG-BPSDMP 2 TAHUN 2025.pdf
AshifaRamadhani
 
family health care settings home visit - unit 6 - chn 1 - gnm 1st year.pptx
Priyanshu Anand
 
Types of Literary Text: Poetry and Prose
kaelandreabibit
 
Mga Unang Hakbang Tungo Sa Tao by Joe Vibar Nero.pdf
MariellaTBesana
 
Understanding operators in c language.pptx
auteharshil95
 
UPPER GASTRO INTESTINAL DISORDER.docx
BANDITA PATRA
 
Open Quiz Monsoon Mind Game Final Set.pptx
Sourav Kr Podder
 
HISTORY COLLECTION FOR PSYCHIATRIC PATIENTS.pptx
PoojaSen20
 

Algorithm - Mergesort & Quicksort