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

What's hot (20)

PDF
9.1 Systems of Linear Equations
smiller5
 
PDF
Pca analysis
kunasujitha
 
PPTX
Principal Component Analysis (PCA) and LDA PPT Slides
AbhishekKumar4995
 
PDF
Discrete Mathematics Lecture Notes
FellowBuddy.com
 
PPTX
Pca ppt
Dheeraj Dwivedi
 
PPTX
Dimensional Analysis and its Applications | Physics
askIITians - Creating Engineers & Doctors
 
PPTX
Cluster Analysis
guest0edcaf
 
PDF
Ev4301897903
IJERA Editor
 
PDF
A Method for Solving Balanced Intuitionistic Fuzzy Assignment Problem
Navodaya Institute of Technology
 
PPTX
Lecture 6.1 6.2 bt
btmathematics
 
DOCX
025 chapter iv
edwin caniete
 
PDF
Kernal based speaker specific feature extraction and its applications in iTau...
TELKOMNIKA JOURNAL
 
PDF
Data Science - Part VII - Cluster Analysis
Derek Kane
 
PPTX
Course - Discrete Mathematics
metamath
 
PDF
Lesson 31
Avijit Kumar
 
PPTX
integration
Maksudur Rahman Maruf
 
PPTX
Hierarchical Clustering
Megha Sharma
 
PPTX
Dynamic pooling and unfolding recursive autoencoders for paraphrase detection
Koza Ozawa
 
PDF
Intro to Discrete Mathematics
asad faraz
 
PPTX
Lect4 principal component analysis-I
hktripathy
 
9.1 Systems of Linear Equations
smiller5
 
Pca analysis
kunasujitha
 
Principal Component Analysis (PCA) and LDA PPT Slides
AbhishekKumar4995
 
Discrete Mathematics Lecture Notes
FellowBuddy.com
 
Dimensional Analysis and its Applications | Physics
askIITians - Creating Engineers & Doctors
 
Cluster Analysis
guest0edcaf
 
Ev4301897903
IJERA Editor
 
A Method for Solving Balanced Intuitionistic Fuzzy Assignment Problem
Navodaya Institute of Technology
 
Lecture 6.1 6.2 bt
btmathematics
 
025 chapter iv
edwin caniete
 
Kernal based speaker specific feature extraction and its applications in iTau...
TELKOMNIKA JOURNAL
 
Data Science - Part VII - Cluster Analysis
Derek Kane
 
Course - Discrete Mathematics
metamath
 
Lesson 31
Avijit Kumar
 
Hierarchical Clustering
Megha Sharma
 
Dynamic pooling and unfolding recursive autoencoders for paraphrase detection
Koza Ozawa
 
Intro to Discrete Mathematics
asad faraz
 
Lect4 principal component analysis-I
hktripathy
 

Similar to Merge sort data structures (20)

PDF
Daa chapter 2
B.Kirron Reddi
 
PPT
Divide and conquer algorithm
CHANDAN KUMAR
 
PDF
Disign and Analysis for algorithm in computer science and technology
ritikkumarchaudhury7
 
PPTX
Algorithm in computer science
Riazul Islam
 
PPTX
Divide and Conquer - Part 1
Amrinder Arora
 
PPTX
algorithm design.pptx
ssuserd11e4a
 
PDF
DS & Algo 3 - Divide and Conquer
Mohammad Imam Hossain
 
PPTX
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Amrinder Arora
 
PPTX
Divide and Conquer / Greedy Techniques
Nirmalavenkatachalam
 
DOC
algorithm Unit 2
Monika Choudhery
 
DOC
Unit 2 in daa
Nv Thejaswini
 
PDF
02 Notes Divide and Conquer
Andres Mendez-Vazquez
 
PDF
Book.pdf01_Intro.ppt algorithm for preperation stu used
archu26
 
PPTX
Greedy Algorithms
Amrinder Arora
 
PDF
divide and conquer algorithm slides for information and review
HFLEX
 
PPTX
Algorithm Design Techiques, divide and conquer
Minakshee Patil
 
PPTX
Algorithms Design Patterns
Ashwin Shiv
 
PDF
A New Method Based on MDA to Enhance the Face Recognition Performance
CSCJournals
 
PPT
Lecture 8 dynamic programming
Oye Tu
 
DOCX
Mb0048 operations research
smumbahelp
 
Daa chapter 2
B.Kirron Reddi
 
Divide and conquer algorithm
CHANDAN KUMAR
 
Disign and Analysis for algorithm in computer science and technology
ritikkumarchaudhury7
 
Algorithm in computer science
Riazul Islam
 
Divide and Conquer - Part 1
Amrinder Arora
 
algorithm design.pptx
ssuserd11e4a
 
DS & Algo 3 - Divide and Conquer
Mohammad Imam Hossain
 
Divide and Conquer - Part II - Quickselect and Closest Pair of Points
Amrinder Arora
 
Divide and Conquer / Greedy Techniques
Nirmalavenkatachalam
 
algorithm Unit 2
Monika Choudhery
 
Unit 2 in daa
Nv Thejaswini
 
02 Notes Divide and Conquer
Andres Mendez-Vazquez
 
Book.pdf01_Intro.ppt algorithm for preperation stu used
archu26
 
Greedy Algorithms
Amrinder Arora
 
divide and conquer algorithm slides for information and review
HFLEX
 
Algorithm Design Techiques, divide and conquer
Minakshee Patil
 
Algorithms Design Patterns
Ashwin Shiv
 
A New Method Based on MDA to Enhance the Face Recognition Performance
CSCJournals
 
Lecture 8 dynamic programming
Oye Tu
 
Mb0048 operations research
smumbahelp
 
Ad

More from chauhankapil (20)

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

Recently uploaded (20)

PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PPTX
ISO/IEC JTC 1/WG 9 (MAR) Convenor Report
Kurata Takeshi
 
PPTX
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
PPTX
Benefits_^0_Challigi😙🏡💐8fenges[1].pptx
akghostmaker
 
PPTX
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
PPTX
site survey architecture student B.arch.
sri02032006
 
PDF
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
PDF
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
PDF
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
PDF
Additional Information in midterm CPE024 (1).pdf
abolisojoy
 
PDF
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
PPT
inherently safer design for engineering.ppt
DhavalShah616893
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
PDF
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
PDF
BioSensors glucose monitoring, cholestrol
nabeehasahar1
 
PPTX
Electron Beam Machining for Production Process
Rajshahi University of Engineering & Technology(RUET), Bangladesh
 
PPTX
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
PPTX
MPMC_Module-2 xxxxxxxxxxxxxxxxxxxxx.pptx
ShivanshVaidya5
 
PPTX
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
PPTX
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
ISO/IEC JTC 1/WG 9 (MAR) Convenor Report
Kurata Takeshi
 
MobileComputingMANET2023 MobileComputingMANET2023.pptx
masterfake98765
 
Benefits_^0_Challigi😙🏡💐8fenges[1].pptx
akghostmaker
 
原版一样(Acadia毕业证书)加拿大阿卡迪亚大学毕业证办理方法
Taqyea
 
site survey architecture student B.arch.
sri02032006
 
Water Design_Manual_2005. KENYA FOR WASTER SUPPLY AND SEWERAGE
DancanNgutuku
 
Unified_Cloud_Comm_Presentation anil singh ppt
anilsingh298751
 
A presentation on the Urban Heat Island Effect
studyfor7hrs
 
Additional Information in midterm CPE024 (1).pdf
abolisojoy
 
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
inherently safer design for engineering.ppt
DhavalShah616893
 
Hashing Introduction , hash functions and techniques
sailajam21
 
ARC--BUILDING-UTILITIES-2-PART-2 (1).pdf
IzzyBaniquedBusto
 
BioSensors glucose monitoring, cholestrol
nabeehasahar1
 
Electron Beam Machining for Production Process
Rajshahi University of Engineering & Technology(RUET), Bangladesh
 
Introduction to Neural Networks and Perceptron Learning Algorithm.pptx
Kayalvizhi A
 
MPMC_Module-2 xxxxxxxxxxxxxxxxxxxxx.pptx
ShivanshVaidya5
 
Pharmaceuticals and fine chemicals.pptxx
jaypa242004
 
Types of Bearing_Specifications_PPT.pptx
PranjulAgrahariAkash
 

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.