SlideShare a Scribd company logo
1 of 30
• By:-
• Gagan.R.Popale-2BV13CS034
• Ankit Gaonkar -2BV13CS014
• Anung Tajo-2BV13CS015
• Alan S Malekar-2BV13CS010
Sorting
WHAT IS SORTING?
 Sorting is the process of
putting a list or a group of
items in a specific order.
Some common sorting criteria
are: alphabetical or numerical.
 Ex:- Merge sort, Quick sort
etc
Merge sort and Quick sort use :
Divide And Conqure Technique
3
 Divide the problem into a number of sub-problems
◦ Similar sub-problems of smaller size
 Conquer the sub-problems
◦ Solve the sub-problems recursively
◦ Sub-problem size small enough  solve the problems in
straightforward manner
 Combine the solutions of the sub-problems
◦ Obtain the solution for the original problem
Merge Sort
In the Beginning…
Invented by
John von Neumann
(1903-1957)
 Follows divide
and conquer
paradigm.
 Developed merge
sort for EDVAC in
1945
Merging
 The key to Merge Sort is merging two
sorted lists into one, such that if you
have two lists X (x1x2…xm) and
Y(y1y2…yn) the resulting list is
Z(z1z2…zm+n)
 Example:
L1 = { 3 8 9 } L2 = { 1 5 7 }
merge(L1, L2) = { 1 3 5 7 8 9 }
Divide And Conquer
1.Divide: Divide the unsorted list into two
sub lists of about half the size.
2.Conquer: Sort each of the two sub lists
recursively until we have list sizes of
length 1,in which case the list itself is
returned.
3.Combine: Merge the two-sorted sub lists
back into one sorted list.
Merge sort algorithm
Merge-Sort (A, n)
if n=1 return
else
n1 ← n2 ← n/2
create array L[n1], R[n2]
for i ← 0 to n1-1 do L[i] ← A[i]
for j ← 0 to n2-1 do R[j] ← A[n1+j]
 Merge-Sort(L, n1)
 Merge-Sort(R, n2)
 Merge(A, L, n1, R, n2 )
Merge Sort Example
99 6 86 15 58 35 86 4 0
99 6 86 15 58 35 86 4 0
Merge Sort Example
99 6 86 15 58 35 86 4 0
99 6 86 15 58 35 86 4 0
86 1599 6 58 35 86 4 0
Merge Sort Example
99 6 86 15 58 35 86 4 0
99 6 86 15 58 35 86 4 0
86 1599 6 58 35 86 4 0
99 6 86 15 58 35 86 4 0
Merge Sort Example
99 6 86 15 58 35 86 4 0
99 6 86 15 58 35 86 4 0
86 1599 6 58 35 86 4 0
99 6 86 15 58 35 86 4 0
4 0
Merge Sort Example
99 6 86 15 58 35 86 4 0
Merge Sort Example
99 6 86 15 58 35 86 0 4
4 0Merge
Merge Sort Example
15 866 99 58 35 0 4 86
99 6 86 15 58 35 86 0 4
Merge
Merge Sort Example
6 15 86 99 0 4 35 58 86
15 866 99 58 35 0 4 86
Merge
Merge Sort Example
0 4 6 15 35 58 86 86 99
6 15 86 99 0 4 35 58 86
Merge
Merge Sort Example
0 4 6 15 35 58 86 86 99
Implementing Merge Sort
 There are two basic ways to implement
merge sort:
In Place: Merging is done with only the input
array
Double Storage: Merging is done with a
temporary array of the same size as the input
array.
20
Merge-Sort Analysis
• Time, merging
log n levels
• Total running time: order of nlogn
• Total Space: order of n
Total time for merging: cn log n
n
n/2 n/2
n/4 n/4 n/4 n/4
Additional
 Merge sort’s merge operation is useful in
online sorting, where the list to be sorted
is received a piece at a time,instead of all
at the beginning..
In this We sort each new piece that is
received using any sorting algorithm, and
then merge it into our sorted list so far
using the merge operation.
Finally
Best Case, Average Case, and Worst Case
= O(N logN)
• Storage Requirement:
Double that needed to hold the array to be
sorted.
Daa final
Daa final
Daa final
Daa final
Daa final
Daa final
Daa final
Daa final

More Related Content

What's hot

Data Structure and Algorithms Sorting
Data Structure and Algorithms SortingData Structure and Algorithms Sorting
Data Structure and Algorithms SortingManishPrajapati78
 
Bubble sort
Bubble sortBubble sort
Bubble sortManek Ar
 
Counting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsCounting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsSarvesh Rawat
 
Quick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And AnalysisQuick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And AnalysisSNJ Chaudhary
 
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Lecture 3  data structures & algorithms - sorting techniques - http://techiem...Lecture 3  data structures & algorithms - sorting techniques - http://techiem...
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...Dharmendra Prasad
 
Module 2 Design Analysis and Algorithms
Module 2 Design Analysis and AlgorithmsModule 2 Design Analysis and Algorithms
Module 2 Design Analysis and AlgorithmsCool Guy
 
3.8 quick sort
3.8 quick sort3.8 quick sort
3.8 quick sortKrish_ver2
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting AlgorithmsPranay Neema
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Hossain Md Shakhawat
 
Bucket sort- A Noncomparision Algorithm
Bucket sort- A Noncomparision AlgorithmBucket sort- A Noncomparision Algorithm
Bucket sort- A Noncomparision AlgorithmKrupali Mistry
 

What's hot (20)

Mergesort
MergesortMergesort
Mergesort
 
Data Structure and Algorithms Sorting
Data Structure and Algorithms SortingData Structure and Algorithms Sorting
Data Structure and Algorithms Sorting
 
Bubble sort
Bubble sortBubble sort
Bubble sort
 
Marge Sort
Marge SortMarge Sort
Marge Sort
 
Merge sort
Merge sortMerge sort
Merge sort
 
Sorting
SortingSorting
Sorting
 
Quicksort
QuicksortQuicksort
Quicksort
 
Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort Algorithm - Mergesort & Quicksort
Algorithm - Mergesort & Quicksort
 
Counting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort AlgorithmsCounting Sort and Radix Sort Algorithms
Counting Sort and Radix Sort Algorithms
 
Quick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And AnalysisQuick sort Algorithm Discussion And Analysis
Quick sort Algorithm Discussion And Analysis
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
Quick sort
Quick sortQuick sort
Quick sort
 
24 Cs146 Jc Merge
24 Cs146 Jc Merge24 Cs146 Jc Merge
24 Cs146 Jc Merge
 
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
Lecture 3  data structures & algorithms - sorting techniques - http://techiem...Lecture 3  data structures & algorithms - sorting techniques - http://techiem...
Lecture 3 data structures & algorithms - sorting techniques - http://techiem...
 
Module 2 Design Analysis and Algorithms
Module 2 Design Analysis and AlgorithmsModule 2 Design Analysis and Algorithms
Module 2 Design Analysis and Algorithms
 
3.8 quick sort
3.8 quick sort3.8 quick sort
3.8 quick sort
 
Sorting
SortingSorting
Sorting
 
Sorting Algorithms
Sorting AlgorithmsSorting Algorithms
Sorting Algorithms
 
Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)Counting sort(Non Comparison Sort)
Counting sort(Non Comparison Sort)
 
Bucket sort- A Noncomparision Algorithm
Bucket sort- A Noncomparision AlgorithmBucket sort- A Noncomparision Algorithm
Bucket sort- A Noncomparision Algorithm
 

Viewers also liked

Presentation on binary search, quick sort, merge sort and problems
Presentation on binary search, quick sort, merge sort  and problemsPresentation on binary search, quick sort, merge sort  and problems
Presentation on binary search, quick sort, merge sort and problemsSumita Das
 
Basic Problems and Solving Algorithms
Basic Problems and Solving AlgorithmsBasic Problems and Solving Algorithms
Basic Problems and Solving AlgorithmsNopadon Juneam
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1Amrinder Arora
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sortMadhu Bala
 
Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap SortMohammed Hussein
 
Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-SortTareq Hasan
 

Viewers also liked (10)

02. divide and conquer
02. divide and conquer02. divide and conquer
02. divide and conquer
 
Presentation on binary search, quick sort, merge sort and problems
Presentation on binary search, quick sort, merge sort  and problemsPresentation on binary search, quick sort, merge sort  and problems
Presentation on binary search, quick sort, merge sort and problems
 
Basic Problems and Solving Algorithms
Basic Problems and Solving AlgorithmsBasic Problems and Solving Algorithms
Basic Problems and Solving Algorithms
 
Merge sort and quick sort
Merge sort and quick sortMerge sort and quick sort
Merge sort and quick sort
 
Sorting
SortingSorting
Sorting
 
Divide and Conquer - Part 1
Divide and Conquer - Part 1Divide and Conquer - Part 1
Divide and Conquer - Part 1
 
Divide and conquer - Quick sort
Divide and conquer - Quick sortDivide and conquer - Quick sort
Divide and conquer - Quick sort
 
Quick Sort , Merge Sort , Heap Sort
Quick Sort , Merge Sort ,  Heap SortQuick Sort , Merge Sort ,  Heap Sort
Quick Sort , Merge Sort , Heap Sort
 
Quick Sort
Quick SortQuick Sort
Quick Sort
 
Algorithm: Quick-Sort
Algorithm: Quick-SortAlgorithm: Quick-Sort
Algorithm: Quick-Sort
 

Similar to Daa final

merge sort help in language C with algorithms
merge sort help in language C with algorithmsmerge sort help in language C with algorithms
merge sort help in language C with algorithmstahamou4
 
Merge sort analysis and its real time applications
Merge sort analysis and its real time applicationsMerge sort analysis and its real time applications
Merge sort analysis and its real time applicationsyazad dumasia
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.pptLegesseSamuel
 
Lecture 13 data structures and algorithms
Lecture 13 data structures and algorithmsLecture 13 data structures and algorithms
Lecture 13 data structures and algorithmsAakash deep Singhal
 
presentation_mergesortquicksort_1458716068_193111.ppt
presentation_mergesortquicksort_1458716068_193111.pptpresentation_mergesortquicksort_1458716068_193111.ppt
presentation_mergesortquicksort_1458716068_193111.pptajiths82
 
MergesortQuickSort.ppt
MergesortQuickSort.pptMergesortQuickSort.ppt
MergesortQuickSort.pptAliAhmad38278
 
Module 2_ Divide and Conquer Approach.pptx
Module 2_ Divide and Conquer Approach.pptxModule 2_ Divide and Conquer Approach.pptx
Module 2_ Divide and Conquer Approach.pptxnikshaikh786
 
Analysis and Design of Algorithms -Sorting Algorithms and analysis
Analysis and Design of Algorithms -Sorting Algorithms and analysisAnalysis and Design of Algorithms -Sorting Algorithms and analysis
Analysis and Design of Algorithms -Sorting Algorithms and analysisRadhika Talaviya
 
Divide And Conquer.pptx
Divide And Conquer.pptxDivide And Conquer.pptx
Divide And Conquer.pptxSHAILIPATEL19
 
Algorithim lec1.pptx
Algorithim lec1.pptxAlgorithim lec1.pptx
Algorithim lec1.pptxrediet43
 
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 printAbdii Rashid
 
(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sortingFadhil Ismail
 
insertion sort-new.pdf
insertion sort-new.pdfinsertion sort-new.pdf
insertion sort-new.pdfObedurRahman1
 

Similar to Daa final (20)

sorting-160810203705.pptx
sorting-160810203705.pptxsorting-160810203705.pptx
sorting-160810203705.pptx
 
merge sort help in language C with algorithms
merge sort help in language C with algorithmsmerge sort help in language C with algorithms
merge sort help in language C with algorithms
 
Merge sort analysis and its real time applications
Merge sort analysis and its real time applicationsMerge sort analysis and its real time applications
Merge sort analysis and its real time applications
 
Advanced s and s algorithm.ppt
Advanced s and s algorithm.pptAdvanced s and s algorithm.ppt
Advanced s and s algorithm.ppt
 
Lecture 13 data structures and algorithms
Lecture 13 data structures and algorithmsLecture 13 data structures and algorithms
Lecture 13 data structures and algorithms
 
sorting
sortingsorting
sorting
 
presentation_mergesortquicksort_1458716068_193111.ppt
presentation_mergesortquicksort_1458716068_193111.pptpresentation_mergesortquicksort_1458716068_193111.ppt
presentation_mergesortquicksort_1458716068_193111.ppt
 
MergesortQuickSort.ppt
MergesortQuickSort.pptMergesortQuickSort.ppt
MergesortQuickSort.ppt
 
Module 2_ Divide and Conquer Approach.pptx
Module 2_ Divide and Conquer Approach.pptxModule 2_ Divide and Conquer Approach.pptx
Module 2_ Divide and Conquer Approach.pptx
 
Analysis and Design of Algorithms -Sorting Algorithms and analysis
Analysis and Design of Algorithms -Sorting Algorithms and analysisAnalysis and Design of Algorithms -Sorting Algorithms and analysis
Analysis and Design of Algorithms -Sorting Algorithms and analysis
 
Divide And Conquer.pptx
Divide And Conquer.pptxDivide And Conquer.pptx
Divide And Conquer.pptx
 
sorting_part1.ppt
sorting_part1.pptsorting_part1.ppt
sorting_part1.ppt
 
Algorithim lec1.pptx
Algorithim lec1.pptxAlgorithim lec1.pptx
Algorithim lec1.pptx
 
Merge sort
Merge sortMerge sort
Merge sort
 
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
 
(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting(Data Structure) Chapter11 searching & sorting
(Data Structure) Chapter11 searching & sorting
 
Lec34
Lec34Lec34
Lec34
 
Sortings .pptx
Sortings .pptxSortings .pptx
Sortings .pptx
 
sorting.pptx
sorting.pptxsorting.pptx
sorting.pptx
 
insertion sort-new.pdf
insertion sort-new.pdfinsertion sort-new.pdf
insertion sort-new.pdf
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting DataJhengPantaleon
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
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
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
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
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
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
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfUmakantAnnand
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data_Math 4-Q4 Week 5.pptx Steps in Collecting Data
_Math 4-Q4 Week 5.pptx Steps in Collecting Data
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.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
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
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
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
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
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
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
 
Concept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.CompdfConcept of Vouching. B.Com(Hons) /B.Compdf
Concept of Vouching. B.Com(Hons) /B.Compdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 

Daa final

  • 1. • By:- • Gagan.R.Popale-2BV13CS034 • Ankit Gaonkar -2BV13CS014 • Anung Tajo-2BV13CS015 • Alan S Malekar-2BV13CS010 Sorting
  • 2. WHAT IS SORTING?  Sorting is the process of putting a list or a group of items in a specific order. Some common sorting criteria are: alphabetical or numerical.  Ex:- Merge sort, Quick sort etc
  • 3. Merge sort and Quick sort use : Divide And Conqure Technique 3  Divide the problem into a number of sub-problems ◦ Similar sub-problems of smaller size  Conquer the sub-problems ◦ Solve the sub-problems recursively ◦ Sub-problem size small enough  solve the problems in straightforward manner  Combine the solutions of the sub-problems ◦ Obtain the solution for the original problem
  • 5. In the Beginning… Invented by John von Neumann (1903-1957)  Follows divide and conquer paradigm.  Developed merge sort for EDVAC in 1945
  • 6. Merging  The key to Merge Sort is merging two sorted lists into one, such that if you have two lists X (x1x2…xm) and Y(y1y2…yn) the resulting list is Z(z1z2…zm+n)  Example: L1 = { 3 8 9 } L2 = { 1 5 7 } merge(L1, L2) = { 1 3 5 7 8 9 }
  • 7. Divide And Conquer 1.Divide: Divide the unsorted list into two sub lists of about half the size. 2.Conquer: Sort each of the two sub lists recursively until we have list sizes of length 1,in which case the list itself is returned. 3.Combine: Merge the two-sorted sub lists back into one sorted list.
  • 8. Merge sort algorithm Merge-Sort (A, n) if n=1 return else n1 ← n2 ← n/2 create array L[n1], R[n2] for i ← 0 to n1-1 do L[i] ← A[i] for j ← 0 to n2-1 do R[j] ← A[n1+j]  Merge-Sort(L, n1)  Merge-Sort(R, n2)  Merge(A, L, n1, R, n2 )
  • 9. Merge Sort Example 99 6 86 15 58 35 86 4 0 99 6 86 15 58 35 86 4 0
  • 10. Merge Sort Example 99 6 86 15 58 35 86 4 0 99 6 86 15 58 35 86 4 0 86 1599 6 58 35 86 4 0
  • 11. Merge Sort Example 99 6 86 15 58 35 86 4 0 99 6 86 15 58 35 86 4 0 86 1599 6 58 35 86 4 0 99 6 86 15 58 35 86 4 0
  • 12. Merge Sort Example 99 6 86 15 58 35 86 4 0 99 6 86 15 58 35 86 4 0 86 1599 6 58 35 86 4 0 99 6 86 15 58 35 86 4 0 4 0
  • 13. Merge Sort Example 99 6 86 15 58 35 86 4 0
  • 14. Merge Sort Example 99 6 86 15 58 35 86 0 4 4 0Merge
  • 15. Merge Sort Example 15 866 99 58 35 0 4 86 99 6 86 15 58 35 86 0 4 Merge
  • 16. Merge Sort Example 6 15 86 99 0 4 35 58 86 15 866 99 58 35 0 4 86 Merge
  • 17. Merge Sort Example 0 4 6 15 35 58 86 86 99 6 15 86 99 0 4 35 58 86 Merge
  • 18. Merge Sort Example 0 4 6 15 35 58 86 86 99
  • 19. Implementing Merge Sort  There are two basic ways to implement merge sort: In Place: Merging is done with only the input array Double Storage: Merging is done with a temporary array of the same size as the input array.
  • 20. 20 Merge-Sort Analysis • Time, merging log n levels • Total running time: order of nlogn • Total Space: order of n Total time for merging: cn log n n n/2 n/2 n/4 n/4 n/4 n/4
  • 21. Additional  Merge sort’s merge operation is useful in online sorting, where the list to be sorted is received a piece at a time,instead of all at the beginning.. In this We sort each new piece that is received using any sorting algorithm, and then merge it into our sorted list so far using the merge operation.
  • 22. Finally Best Case, Average Case, and Worst Case = O(N logN) • Storage Requirement: Double that needed to hold the array to be sorted.