SlideShare a Scribd company logo
1 of 13
Submitted to- Submitted by-
Mrs. Randeep Bhatia Ms. kajal sharma
(AP in cs dept) MCA5th sem
1718781
SORTING
Sorting and searching are the two most common
operations performed on data stored in
Computers . Most of the data structures that we
have studied so far are primarily designed to make
sorting and searching easier and more efficient on
the data stored in the structure.
sorting refers to the process
of arranging data in a particular order such as
ascending or descending order . An ascending
sort of five integers{20,10,60,45,25}produces
{10,20,25,45,60}where as descending sort produces
{60,45,25,20,10}.
The main objective of sorting is to organize
the data so meaningful .
Methods of sorting
• Internal sorting-In Internal sorting ,all of the data which
is to be sorted can be held in primary memory(ram) during
the sorting algorithms.
• External sorting-In external sorting ,all the data to be
sorted can’t be held in the primary memory at one time of
the data has to be sorted in secondary storage devices
such as hard disk, floppy disk etc.
Types of sorting
• Insertion sort .
• Selection sort .
• Merge sort .
• Heap sort .
• Radix sort .
• Bubble sort .
Time complexity of merge sort
F(n)=o(nlog2n)
Merge sort
Merge sort is a well known sorting algorithm
invented by john von Neumann in 1945.It is based
on the divide and conquer strategy in which we
divide the data into smaller pieces , recursively
conquer each piece and merge the result until the
original list is rebuild to a sorted one .
The merge sort algorithm divides the given
list to be sorted into two subsists of approximately
half size , sorts each subsists independently and
then merge the two subsists into a single sorted list.
Original list
We begin merge sort by first dividing the original
array into two sub arrays of approximately equal size.
Thus we divide the array into sub arrays as follows
Original list is divided into two halves
Example :-
our aim is to sort each sub array so that it can be
merged later. Now consider the left sub array
which is again divided into two sub arrays as
Left sub array subdivided into two halves
To each of these sub arrays again apply the same
method that divides each of these into sub arrays of
one element each
Merging of sub arrays
Right sub array subdivided into two halves
our aim is to sort each sub array so that it can be
merged later. Now consider the left sub array which
is again divided into two sub arrays as
To each of these sub arrays again apply the same
method that divides each of these into sub
arrays of one element each
Dividing technique
Merging technique
Advantages
• It can be applied to files of any size.
• Reading of the input during the run –creation
step is sequential.
• If heap sort is used for the in-memory part of
the merge ,its operation can be overlapped.
Disadvantages
• It requires extra space.
• Merge sort requires more space than other
sort.
• Merge sort is less efficient than other sort.
Sorting and Merge Sort Explained

More Related Content

What's hot

Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureBalwant Gorad
 
04 brute force
04 brute force04 brute force
04 brute forceHira Gul
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting AlgorithmsPranay Neema
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sortingKaushal Shah
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sortMadhu Bala
 
Binary search in data structure
Binary search in data structureBinary search in data structure
Binary search in data structureMeherul1234
 
Sorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha MajumderSorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha MajumderAshin Guha Majumder
 
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...Umesh Kumar
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSGokul Hari
 

What's hot (20)

Searching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data StructureSearching and Sorting Techniques in Data Structure
Searching and Sorting Techniques in Data Structure
 
04 brute force
04 brute force04 brute force
04 brute force
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Data Structures - Searching & sorting
Data Structures - Searching & sortingData Structures - Searching & sorting
Data Structures - Searching & sorting
 
Binary search
Binary searchBinary search
Binary search
 
Merge sort algorithm
Merge sort algorithmMerge sort algorithm
Merge sort algorithm
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
 
Divide and conquer
Divide and conquerDivide and conquer
Divide and conquer
 
Binary search in data structure
Binary search in data structureBinary search in data structure
Binary search in data structure
 
Sorting algorithms
Sorting algorithmsSorting algorithms
Sorting algorithms
 
Insertion sort
Insertion sort Insertion sort
Insertion sort
 
Sorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha MajumderSorting Seminar Presentation by Ashin Guha Majumder
Sorting Seminar Presentation by Ashin Guha Majumder
 
Merge sort algorithm power point presentation
Merge sort algorithm power point presentationMerge sort algorithm power point presentation
Merge sort algorithm power point presentation
 
Insertion sort algorithm power point presentation
Insertion  sort algorithm power point presentation Insertion  sort algorithm power point presentation
Insertion sort algorithm power point presentation
 
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
PPT On Sorting And Searching Concepts In Data Structure | In Programming Lang...
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Selection sorting
Selection sortingSelection sorting
Selection sorting
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Presentation-Merge Sort
Presentation-Merge SortPresentation-Merge Sort
Presentation-Merge Sort
 

Similar to Sorting and Merge Sort Explained

SORTING techniques.pptx
SORTING techniques.pptxSORTING techniques.pptx
SORTING techniques.pptxDr.Shweta
 
linked_list.pdf [for undergraduate students
linked_list.pdf [for undergraduate studentslinked_list.pdf [for undergraduate students
linked_list.pdf [for undergraduate studentsSazzadulIslam42
 
Data Structure & Algorithms - Operations
Data Structure & Algorithms - OperationsData Structure & Algorithms - Operations
Data Structure & Algorithms - Operationsbabuk110
 
Sorting algorithms in Data Structure
Sorting algorithms in Data StructureSorting algorithms in Data Structure
Sorting algorithms in Data StructureBalamurugan M
 
Sorting And Type of Sorting
Sorting And Type of SortingSorting And Type of Sorting
Sorting And Type of SortingMITULJAMANG
 
Learn Data Structures With Myassignmenthelp.Net
Learn Data Structures With Myassignmenthelp.NetLearn Data Structures With Myassignmenthelp.Net
Learn Data Structures With Myassignmenthelp.NetSteve Johnson
 
DS Module1 (1).pptx
DS Module1 (1).pptxDS Module1 (1).pptx
DS Module1 (1).pptxAnuJoseph95
 
Lecture 2 Data Structure Introduction
Lecture 2 Data Structure IntroductionLecture 2 Data Structure Introduction
Lecture 2 Data Structure IntroductionAbirami A
 
6-Sorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrti...
6-Sorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrti...6-Sorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrti...
6-Sorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrti...trangiaphuc362003181
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structuresunilchute1
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structuresunilchute1
 
Query optimization
Query optimizationQuery optimization
Query optimizationPooja Dixit
 

Similar to Sorting and Merge Sort Explained (20)

data science
data sciencedata science
data science
 
Data Structures 7
Data Structures 7Data Structures 7
Data Structures 7
 
SORTING techniques.pptx
SORTING techniques.pptxSORTING techniques.pptx
SORTING techniques.pptx
 
linked_list.pdf [for undergraduate students
linked_list.pdf [for undergraduate studentslinked_list.pdf [for undergraduate students
linked_list.pdf [for undergraduate students
 
Data Structure & Algorithms - Operations
Data Structure & Algorithms - OperationsData Structure & Algorithms - Operations
Data Structure & Algorithms - Operations
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
 
Sorting.pptx
Sorting.pptxSorting.pptx
Sorting.pptx
 
sorting-160810203705.pptx
sorting-160810203705.pptxsorting-160810203705.pptx
sorting-160810203705.pptx
 
Sorting algorithms in Data Structure
Sorting algorithms in Data StructureSorting algorithms in Data Structure
Sorting algorithms in Data Structure
 
Sorting
SortingSorting
Sorting
 
stack.pptx
stack.pptxstack.pptx
stack.pptx
 
Sorting And Type of Sorting
Sorting And Type of SortingSorting And Type of Sorting
Sorting And Type of Sorting
 
Learn Data Structures With Myassignmenthelp.Net
Learn Data Structures With Myassignmenthelp.NetLearn Data Structures With Myassignmenthelp.Net
Learn Data Structures With Myassignmenthelp.Net
 
DS Module1 (1).pptx
DS Module1 (1).pptxDS Module1 (1).pptx
DS Module1 (1).pptx
 
Lecture 2 Data Structure Introduction
Lecture 2 Data Structure IntroductionLecture 2 Data Structure Introduction
Lecture 2 Data Structure Introduction
 
6-Sorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrti...
6-Sorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrti...6-Sorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrti...
6-Sorrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrti...
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Heap, quick and merge sort
Heap, quick and merge sortHeap, quick and merge sort
Heap, quick and merge sort
 
Query optimization
Query optimizationQuery optimization
Query optimization
 

Recently uploaded

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersSabitha Banu
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 

Recently uploaded (20)

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
DATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginnersDATA STRUCTURE AND ALGORITHM for beginners
DATA STRUCTURE AND ALGORITHM for beginners
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 

Sorting and Merge Sort Explained

  • 1. Submitted to- Submitted by- Mrs. Randeep Bhatia Ms. kajal sharma (AP in cs dept) MCA5th sem 1718781
  • 2. SORTING Sorting and searching are the two most common operations performed on data stored in Computers . Most of the data structures that we have studied so far are primarily designed to make sorting and searching easier and more efficient on the data stored in the structure. sorting refers to the process of arranging data in a particular order such as ascending or descending order . An ascending sort of five integers{20,10,60,45,25}produces
  • 3. {10,20,25,45,60}where as descending sort produces {60,45,25,20,10}. The main objective of sorting is to organize the data so meaningful . Methods of sorting • Internal sorting-In Internal sorting ,all of the data which is to be sorted can be held in primary memory(ram) during the sorting algorithms. • External sorting-In external sorting ,all the data to be sorted can’t be held in the primary memory at one time of the data has to be sorted in secondary storage devices such as hard disk, floppy disk etc.
  • 4. Types of sorting • Insertion sort . • Selection sort . • Merge sort . • Heap sort . • Radix sort . • Bubble sort . Time complexity of merge sort F(n)=o(nlog2n)
  • 5. Merge sort Merge sort is a well known sorting algorithm invented by john von Neumann in 1945.It is based on the divide and conquer strategy in which we divide the data into smaller pieces , recursively conquer each piece and merge the result until the original list is rebuild to a sorted one . The merge sort algorithm divides the given list to be sorted into two subsists of approximately half size , sorts each subsists independently and then merge the two subsists into a single sorted list.
  • 6. Original list We begin merge sort by first dividing the original array into two sub arrays of approximately equal size. Thus we divide the array into sub arrays as follows Original list is divided into two halves Example :-
  • 7. our aim is to sort each sub array so that it can be merged later. Now consider the left sub array which is again divided into two sub arrays as Left sub array subdivided into two halves To each of these sub arrays again apply the same method that divides each of these into sub arrays of one element each
  • 8. Merging of sub arrays Right sub array subdivided into two halves our aim is to sort each sub array so that it can be merged later. Now consider the left sub array which is again divided into two sub arrays as
  • 9. To each of these sub arrays again apply the same method that divides each of these into sub arrays of one element each Dividing technique
  • 11. Advantages • It can be applied to files of any size. • Reading of the input during the run –creation step is sequential. • If heap sort is used for the in-memory part of the merge ,its operation can be overlapped.
  • 12. Disadvantages • It requires extra space. • Merge sort requires more space than other sort. • Merge sort is less efficient than other sort.