SlideShare a Scribd company logo
1 of 16
Merge and Merge Sorting
Presentation
Presented By:
Sania Rana
Merge Sort:
 It is invented by John Von Neumann (1903-1957).
 A sorting technique based on divide and conquer technique. With
worst case complexity being O(n log n), it is one of the most respected
algorithms.
 Merge sort first divides the array into equal halves and then combines
them in a sorted manner.
Divide and Conquer:
Merge Sort
Divide
Conquer
►Divide: Divide the unsorted list into two sub-lists of about half the size.
►Conquer: Sort each of the two sub-list recursively until we have list sizes of length 1, in
which case the list itself is returned.
►Combine: Merge the two sorted sub-lists back into one sorted list.
Merge sort
algorithm of array
ARR contains N
elements:
 START
 IF array ARR has only one element, it’s
already sorted, THEN
EXIT
ELSE
Divide the array recursively into two
halves until it cannot be further divided.
END IF
 Merge the smaller sub-arrays into new
array in sorted order
 EXIT
Merge sort example:
 Consider a sequence of numbers
7, 2, 9, 4, 3, 8, 6, 1
 Divide the Array into two parts
7, 2, 9, 4 | 3, 8, 6, 1
Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7,2 | 9,4
► Divide the Array into two parts again.
Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7, 2 | 9, 4
7 | 2
► Break each element into single part.
Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7, 2 | 9, 4
7 | 2
7
► Sort the elements from smallest to largest.
Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7, 2 | 9, 4
7 | 2
7
2
►Sort the elements from smallest to largest.
Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7, 2 | 9, 4
7|2 2 7
7
2
► Sort the elements from smallest to largest.
Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7, 2 | 9, 4
7|2 2 7
7
2
9|4 4 9
9
4
► Sort the elements from smallest to largest.
Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7, 2 | 9, 4 2 4 7 9
7|2 2 7
7
2
9|4 4 9
9
4
►Merge the divided sorted array together.
Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7, 2 | 9, 4 2 4 7 9
7|2 2 7
7
2
9|4 4 9
9
4
3, 8 | 6, 1 1 3 6 8
3|8 3 8
3
8
6|1 1 6
6
1
►Merge the divided sorted array together.
Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1 1 2 3 4 6 7 8 9
7, 2 | 9, 4 2 4 7 9
7|2 2 7
7
2
9|4 4 9
9
4
3, 8 | 6, 1 1 3 6 8
3|8 3 8
3
8
6|1 1 6
6
1
► The array has been sorted.
Summary
presentation
Merge
Divide And Conquer
Example
Introduction
Merge Sort
Algorithm
Thank You

More Related Content

What's hot (13)

Maths Class 10th Projects
Maths Class 10th ProjectsMaths Class 10th Projects
Maths Class 10th Projects
 
Addition with different strategies
Addition with different strategies Addition with different strategies
Addition with different strategies
 
M.S. 442 Carroll Gardens School For Innovation 6th Grade Math Info Slide
M.S. 442 Carroll Gardens School For Innovation 6th Grade Math Info SlideM.S. 442 Carroll Gardens School For Innovation 6th Grade Math Info Slide
M.S. 442 Carroll Gardens School For Innovation 6th Grade Math Info Slide
 
Mergesort
MergesortMergesort
Mergesort
 
Chapter 3
Chapter 3Chapter 3
Chapter 3
 
Mean median mode
Mean median modeMean median mode
Mean median mode
 
Sets and set operations
Sets and set operationsSets and set operations
Sets and set operations
 
Sulpcegu5e ppt 2_1
Sulpcegu5e ppt 2_1Sulpcegu5e ppt 2_1
Sulpcegu5e ppt 2_1
 
September 17
September 17September 17
September 17
 
Minimization Technique by Rishov Mal
Minimization Technique by Rishov MalMinimization Technique by Rishov Mal
Minimization Technique by Rishov Mal
 
SCATTER PLOTS
SCATTER PLOTSSCATTER PLOTS
SCATTER PLOTS
 
SETS USING VENN DIAGRAMS
SETS USING VENN DIAGRAMSSETS USING VENN DIAGRAMS
SETS USING VENN DIAGRAMS
 
1 Excel Basics & Diff Error Prop
1 Excel Basics & Diff Error Prop1 Excel Basics & Diff Error Prop
1 Excel Basics & Diff Error Prop
 

Similar to Merge and merge sorting

presentation on b tress. heap trees.hashing
presentation on b tress. heap trees.hashingpresentation on b tress. heap trees.hashing
presentation on b tress. heap trees.hashing
Bindiya syed
 
02 Representing Sets and Types of Sets.pptx
02 Representing Sets and Types of Sets.pptx02 Representing Sets and Types of Sets.pptx
02 Representing Sets and Types of Sets.pptx
MerrykrisIgnacio
 
Sorting algorithums > Data Structures & Algorithums
Sorting algorithums  > Data Structures & AlgorithumsSorting algorithums  > Data Structures & Algorithums
Sorting algorithums > Data Structures & Algorithums
Ain-ul-Moiz Khawaja
 

Similar to Merge and merge sorting (20)

Merge sort
Merge sortMerge sort
Merge sort
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.ppt
 
Shell sorting
Shell sortingShell sorting
Shell sorting
 
TOUSIF AZIM_BDS 101[1].pptx
TOUSIF AZIM_BDS 101[1].pptxTOUSIF AZIM_BDS 101[1].pptx
TOUSIF AZIM_BDS 101[1].pptx
 
Lec34
Lec34Lec34
Lec34
 
Lesson 1.1 basic ideas of sets part 1
Lesson 1.1   basic ideas of sets part 1Lesson 1.1   basic ideas of sets part 1
Lesson 1.1 basic ideas of sets part 1
 
13_median.pdf
13_median.pdf13_median.pdf
13_median.pdf
 
Daa final
Daa finalDaa final
Daa final
 
sorting.pptx
sorting.pptxsorting.pptx
sorting.pptx
 
arrayppt.pptx
arrayppt.pptxarrayppt.pptx
arrayppt.pptx
 
presentation on b tress. heap trees.hashing
presentation on b tress. heap trees.hashingpresentation on b tress. heap trees.hashing
presentation on b tress. heap trees.hashing
 
Lesson 3 - matrix multiplication
Lesson 3 - matrix multiplicationLesson 3 - matrix multiplication
Lesson 3 - matrix multiplication
 
Array Presentation
Array PresentationArray Presentation
Array Presentation
 
Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0Algorithms with-java-advanced-1.0
Algorithms with-java-advanced-1.0
 
Dl36675677
Dl36675677Dl36675677
Dl36675677
 
02 Representing Sets and Types of Sets.pptx
02 Representing Sets and Types of Sets.pptx02 Representing Sets and Types of Sets.pptx
02 Representing Sets and Types of Sets.pptx
 
Array ppt
Array pptArray ppt
Array ppt
 
Array.pdf
Array.pdfArray.pdf
Array.pdf
 
Sorting algorithums > Data Structures & Algorithums
Sorting algorithums  > Data Structures & AlgorithumsSorting algorithums  > Data Structures & Algorithums
Sorting algorithums > Data Structures & Algorithums
 
Chapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for printChapter 8 advanced sorting and hashing for print
Chapter 8 advanced sorting and hashing for print
 

Recently uploaded

obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
yulianti213969
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
zifhagzkk
 
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
acoha1
 
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get CytotecAbortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
Huawei Ransomware Protection Storage Solution Technical Overview Presentation...
Huawei Ransomware Protection Storage Solution Technical Overview Presentation...Huawei Ransomware Protection Storage Solution Technical Overview Presentation...
Huawei Ransomware Protection Storage Solution Technical Overview Presentation...
LuisMiguelPaz5
 
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Riyadh +966572737505 get cytotec
 
sourabh vyas1222222222222222222244444444
sourabh vyas1222222222222222222244444444sourabh vyas1222222222222222222244444444
sourabh vyas1222222222222222222244444444
saurabvyas476
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
q6pzkpark
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
ahmedjiabur940
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
wsppdmt
 

Recently uploaded (20)

Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
Identify Rules that Predict Patient’s Heart Disease - An Application of Decis...
 
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
5CL-ADBA,5cladba, Chinese supplier, safety is guaranteed
 
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
Jual Obat Aborsi Bandung (Asli No.1) Wa 082134680322 Klinik Obat Penggugur Ka...
 
社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction社内勉強会資料_Object Recognition as Next Token Prediction
社内勉強会資料_Object Recognition as Next Token Prediction
 
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
obat aborsi Tarakan wa 081336238223 jual obat aborsi cytotec asli di Tarakan9...
 
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
如何办理(Dalhousie毕业证书)达尔豪斯大学毕业证成绩单留信学历认证
 
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
如何办理(WashU毕业证书)圣路易斯华盛顿大学毕业证成绩单本科硕士学位证留信学历认证
 
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get CytotecAbortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
Abortion pills in Doha {{ QATAR }} +966572737505) Get Cytotec
 
Huawei Ransomware Protection Storage Solution Technical Overview Presentation...
Huawei Ransomware Protection Storage Solution Technical Overview Presentation...Huawei Ransomware Protection Storage Solution Technical Overview Presentation...
Huawei Ransomware Protection Storage Solution Technical Overview Presentation...
 
Abortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get CytotecAbortion pills in Jeddah | +966572737505 | Get Cytotec
Abortion pills in Jeddah | +966572737505 | Get Cytotec
 
Seven tools of quality control.slideshare
Seven tools of quality control.slideshareSeven tools of quality control.slideshare
Seven tools of quality control.slideshare
 
Ranking and Scoring Exercises for Research
Ranking and Scoring Exercises for ResearchRanking and Scoring Exercises for Research
Ranking and Scoring Exercises for Research
 
sourabh vyas1222222222222222222244444444
sourabh vyas1222222222222222222244444444sourabh vyas1222222222222222222244444444
sourabh vyas1222222222222222222244444444
 
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24  Building Real-Time Pipelines With FLaNKDATA SUMMIT 24  Building Real-Time Pipelines With FLaNK
DATA SUMMIT 24 Building Real-Time Pipelines With FLaNK
 
Digital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham WareDigital Transformation Playbook by Graham Ware
Digital Transformation Playbook by Graham Ware
 
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
一比一原版(曼大毕业证书)曼尼托巴大学毕业证成绩单留信学历认证一手价格
 
jll-asia-pacific-capital-tracker-1q24.pdf
jll-asia-pacific-capital-tracker-1q24.pdfjll-asia-pacific-capital-tracker-1q24.pdf
jll-asia-pacific-capital-tracker-1q24.pdf
 
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi ArabiaIn Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
In Riyadh ((+919101817206)) Cytotec kit @ Abortion Pills Saudi Arabia
 
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
如何办理英国诺森比亚大学毕业证(NU毕业证书)成绩单原件一模一样
 
Harnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptxHarnessing the Power of GenAI for BI and Reporting.pptx
Harnessing the Power of GenAI for BI and Reporting.pptx
 

Merge and merge sorting

  • 1. Merge and Merge Sorting Presentation Presented By: Sania Rana
  • 2. Merge Sort:  It is invented by John Von Neumann (1903-1957).  A sorting technique based on divide and conquer technique. With worst case complexity being O(n log n), it is one of the most respected algorithms.  Merge sort first divides the array into equal halves and then combines them in a sorted manner.
  • 3. Divide and Conquer: Merge Sort Divide Conquer ►Divide: Divide the unsorted list into two sub-lists of about half the size. ►Conquer: Sort each of the two sub-list recursively until we have list sizes of length 1, in which case the list itself is returned. ►Combine: Merge the two sorted sub-lists back into one sorted list.
  • 4. Merge sort algorithm of array ARR contains N elements:  START  IF array ARR has only one element, it’s already sorted, THEN EXIT ELSE Divide the array recursively into two halves until it cannot be further divided. END IF  Merge the smaller sub-arrays into new array in sorted order  EXIT
  • 5. Merge sort example:  Consider a sequence of numbers 7, 2, 9, 4, 3, 8, 6, 1  Divide the Array into two parts 7, 2, 9, 4 | 3, 8, 6, 1
  • 6. Merge sort example: 7, 2, 9, 4 | 3, 8, 6, 1 7,2 | 9,4 ► Divide the Array into two parts again.
  • 7. Merge sort example: 7, 2, 9, 4 | 3, 8, 6, 1 7, 2 | 9, 4 7 | 2 ► Break each element into single part.
  • 8. Merge sort example: 7, 2, 9, 4 | 3, 8, 6, 1 7, 2 | 9, 4 7 | 2 7 ► Sort the elements from smallest to largest.
  • 9. Merge sort example: 7, 2, 9, 4 | 3, 8, 6, 1 7, 2 | 9, 4 7 | 2 7 2 ►Sort the elements from smallest to largest.
  • 10. Merge sort example: 7, 2, 9, 4 | 3, 8, 6, 1 7, 2 | 9, 4 7|2 2 7 7 2 ► Sort the elements from smallest to largest.
  • 11. Merge sort example: 7, 2, 9, 4 | 3, 8, 6, 1 7, 2 | 9, 4 7|2 2 7 7 2 9|4 4 9 9 4 ► Sort the elements from smallest to largest.
  • 12. Merge sort example: 7, 2, 9, 4 | 3, 8, 6, 1 7, 2 | 9, 4 2 4 7 9 7|2 2 7 7 2 9|4 4 9 9 4 ►Merge the divided sorted array together.
  • 13. Merge sort example: 7, 2, 9, 4 | 3, 8, 6, 1 7, 2 | 9, 4 2 4 7 9 7|2 2 7 7 2 9|4 4 9 9 4 3, 8 | 6, 1 1 3 6 8 3|8 3 8 3 8 6|1 1 6 6 1 ►Merge the divided sorted array together.
  • 14. Merge sort example: 7, 2, 9, 4 | 3, 8, 6, 1 1 2 3 4 6 7 8 9 7, 2 | 9, 4 2 4 7 9 7|2 2 7 7 2 9|4 4 9 9 4 3, 8 | 6, 1 1 3 6 8 3|8 3 8 3 8 6|1 1 6 6 1 ► The array has been sorted.