SlideShare a Scribd company logo
Merge Sort in Data Structures
Prof. Neeraj Bhargava
Kapil Chauhan
Department of Computer Science
School of Engineering & Systems Sciences
MDS University, Ajmer
Introduction
 Merge Sort follows the rule of Divide and Conquer to
sort a given set of numbers/elements, recursively,
hence consuming less time.
 Merge sort , runs in O(n*log n) time in all the cases.
Divide and Conquer
 If we can break a single big problem into smaller sub-
problems, solve the smaller sub-problems and
combine their solutions to find the solution for the
original big problem, it becomes easier to solve the
whole problem.
 The concept of Divide and Conquer involves three
steps:
 Divide the problem into multiple small problems.
Cont..
 Conquer the subproblems by solving them. The idea
is to break down the problem into atomic
subproblems, where they are actually solved.
 Combine the solutions of the subproblems to find the
solution of the actual problem.
Divide and Conquer
Algorithm
 MergeSort(arr[], l, r)
 If r > l
 1. Find the middle point to divide the array into two
halves:
 middle m = (l+r)/2
 2. Call mergeSort for first half:
 Call mergeSort(arr, l, m)
 3. Call mergeSort for second half:
 Call mergeSort(arr, m+1, r)
 4. Merge the two halves sorted in step 2 and 3:
 Call merge(arr, l, m, r)
Example
Assignment
 Explain Merge Sort in data structure with suitable
example and discuss basic operation.

More Related Content

PPS
Revised DEMATEL1
PPTX
Applications of Discrete Structures
PPTX
Use of the Tree.
PDF
F5233444
DOCX
Mit202 data base management system(dbms)
KEY
PDF
Ebook mst209 block1_e1i1_n9780749252816_l1 (2)
PDF
Ebook mst209 block3_e1i1_n9780749252830_l1 (2)
Revised DEMATEL1
Applications of Discrete Structures
Use of the Tree.
F5233444
Mit202 data base management system(dbms)
Ebook mst209 block1_e1i1_n9780749252816_l1 (2)
Ebook mst209 block3_e1i1_n9780749252830_l1 (2)

What's hot (20)

PDF
9.1 Systems of Linear Equations
PDF
Pca analysis
PPTX
Principal Component Analysis (PCA) and LDA PPT Slides
PDF
Discrete Mathematics Lecture Notes
PPTX
PPTX
Dimensional Analysis and its Applications | Physics
PPTX
Cluster Analysis
PDF
Ev4301897903
PDF
A Method for Solving Balanced Intuitionistic Fuzzy Assignment Problem
PPTX
Lecture 6.1 6.2 bt
DOCX
025 chapter iv
PDF
Kernal based speaker specific feature extraction and its applications in iTau...
PDF
Data Science - Part VII - Cluster Analysis
PPTX
Course - Discrete Mathematics
PDF
Lesson 31
PPTX
PPTX
Hierarchical Clustering
PPTX
Dynamic pooling and unfolding recursive autoencoders for paraphrase detection
PDF
Intro to Discrete Mathematics
PPTX
Lect4 principal component analysis-I
9.1 Systems of Linear Equations
Pca analysis
Principal Component Analysis (PCA) and LDA PPT Slides
Discrete Mathematics Lecture Notes
Dimensional Analysis and its Applications | Physics
Cluster Analysis
Ev4301897903
A Method for Solving Balanced Intuitionistic Fuzzy Assignment Problem
Lecture 6.1 6.2 bt
025 chapter iv
Kernal based speaker specific feature extraction and its applications in iTau...
Data Science - Part VII - Cluster Analysis
Course - Discrete Mathematics
Lesson 31
Hierarchical Clustering
Dynamic pooling and unfolding recursive autoencoders for paraphrase detection
Intro to Discrete Mathematics
Lect4 principal component analysis-I
Ad

Similar to Merge sort data structures (20)

PPTX
Data structure Merge Sort implementation
PPT
Implication of Merge sort (Artificial Intelligence).ppt
PPTX
Merge Sort with real example using animation
PPTX
Merj sort
PPTX
MergeSort presentation dgdfgdfgdfgg.pptx
PPTX
Merge sort
PPTX
Merge and merge sorting
PPTX
Data Structures and Agorithm: DS 20 Merge Sort.pptx
PPTX
DSA- Merge Sort-a sorting technique.pptx
PPT
Lec 6 Divide and conquer of Data Structures & Algortihms
PPTX
Quick Sort in data structure.pptx
PPT
MergeSort algoritmos de complegidada (1).ppt
PPT
MergeSort.ppt algorithm History and Examples
PPT
MergeSort.ppt algorithm History and Examples
PPT
MergeSort_DATA_strucute_dsa_algorithm.ppt
PPT
MergeSortfbsjbjsfk sdfik k
PPTX
dsa presentation on merge sorting in C++.pptx
PPT
MergeSort.ppt shows how merge sort is done
PPT
Merge sort
PPTX
Data Structure Marge sort Group 5 pptx so
Data structure Merge Sort implementation
Implication of Merge sort (Artificial Intelligence).ppt
Merge Sort with real example using animation
Merj sort
MergeSort presentation dgdfgdfgdfgg.pptx
Merge sort
Merge and merge sorting
Data Structures and Agorithm: DS 20 Merge Sort.pptx
DSA- Merge Sort-a sorting technique.pptx
Lec 6 Divide and conquer of Data Structures & Algortihms
Quick Sort in data structure.pptx
MergeSort algoritmos de complegidada (1).ppt
MergeSort.ppt algorithm History and Examples
MergeSort.ppt algorithm History and Examples
MergeSort_DATA_strucute_dsa_algorithm.ppt
MergeSortfbsjbjsfk sdfik k
dsa presentation on merge sorting in C++.pptx
MergeSort.ppt shows how merge sort is done
Merge sort
Data Structure Marge sort Group 5 pptx so
Ad

More from chauhankapil (20)

PPTX
Gray level transformation
PPTX
Elements of visual perception
PPTX
JSP Client Request
PPTX
Jsp server response
PPTX
Markov decision process
PPTX
RNN basics in deep learning
PPTX
Introduction to generative adversarial networks (GANs)
PPTX
Bayesian probabilistic interference
PPTX
PPTX
Exception handling in java
PPTX
Knowledge acquistion
PPTX
Knowledge based system
PPTX
Introduction of predicate logics
PPTX
Types of inheritance in java
PPTX
Representation of syntax, semantics and Predicate logics
PPTX
Inheritance in java
PPTX
Propositional logic
PPTX
Constructors in java
PPTX
Methods in java
PPT
Circular linked list
Gray level transformation
Elements of visual perception
JSP Client Request
Jsp server response
Markov decision process
RNN basics in deep learning
Introduction to generative adversarial networks (GANs)
Bayesian probabilistic interference
Exception handling in java
Knowledge acquistion
Knowledge based system
Introduction of predicate logics
Types of inheritance in java
Representation of syntax, semantics and Predicate logics
Inheritance in java
Propositional logic
Constructors in java
Methods in java
Circular linked list

Recently uploaded (20)

PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PPTX
Current and future trends in Computer Vision.pptx
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
DOCX
573137875-Attendance-Management-System-original
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPT
Mechanical Engineering MATERIALS Selection
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Safety Seminar civil to be ensured for safe working.
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
Artificial Intelligence
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Current and future trends in Computer Vision.pptx
Model Code of Practice - Construction Work - 21102022 .pdf
573137875-Attendance-Management-System-original
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Mechanical Engineering MATERIALS Selection
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
R24 SURVEYING LAB MANUAL for civil enggi
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
CH1 Production IntroductoryConcepts.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Safety Seminar civil to be ensured for safe working.
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
Foundation to blockchain - A guide to Blockchain Tech
Automation-in-Manufacturing-Chapter-Introduction.pdf
Artificial Intelligence
bas. eng. economics group 4 presentation 1.pptx
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx

Merge sort data structures

  • 1. Merge Sort in Data Structures Prof. Neeraj Bhargava Kapil Chauhan Department of Computer Science School of Engineering & Systems Sciences MDS University, Ajmer
  • 2. Introduction  Merge Sort follows the rule of Divide and Conquer to sort a given set of numbers/elements, recursively, hence consuming less time.  Merge sort , runs in O(n*log n) time in all the cases.
  • 3. Divide and Conquer  If we can break a single big problem into smaller sub- problems, solve the smaller sub-problems and combine their solutions to find the solution for the original big problem, it becomes easier to solve the whole problem.  The concept of Divide and Conquer involves three steps:  Divide the problem into multiple small problems.
  • 4. Cont..  Conquer the subproblems by solving them. The idea is to break down the problem into atomic subproblems, where they are actually solved.  Combine the solutions of the subproblems to find the solution of the actual problem.
  • 6. Algorithm  MergeSort(arr[], l, r)  If r > l  1. Find the middle point to divide the array into two halves:  middle m = (l+r)/2  2. Call mergeSort for first half:  Call mergeSort(arr, l, m)  3. Call mergeSort for second half:  Call mergeSort(arr, m+1, r)  4. Merge the two halves sorted in step 2 and 3:  Call merge(arr, l, m, r)
  • 8. Assignment  Explain Merge Sort in data structure with suitable example and discuss basic operation.