• 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

PDF
Asymptotic Notation
PPTX
Merge Sort vs Quick Sort presentation
PPTX
Top down parsing
PPTX
PROCEDURAL ORIENTED PROGRAMMING VS OBJECT ORIENTED PROGRAMING
PPTX
8 queens problem using back tracking
PDF
Divide and Conquer
PPT
Divide and conquer
PDF
Command line-arguments-in-java-tutorial
Asymptotic Notation
Merge Sort vs Quick Sort presentation
Top down parsing
PROCEDURAL ORIENTED PROGRAMMING VS OBJECT ORIENTED PROGRAMING
8 queens problem using back tracking
Divide and Conquer
Divide and conquer
Command line-arguments-in-java-tutorial

What's hot (20)

PDF
Bottom up parser
PPTX
Travelling salesman dynamic programming
PPT
Parsing
PPTX
Quick Sort
PPTX
Merge sort algorithm
PDF
Longest common subsequence
PDF
Quick sort algorithn
PPTX
Types of grammer - TOC
PPTX
LALR Parser Presentation ppt
PPTX
daa-unit-3-greedy method
PPT
Recursion tree method
PPT
Heap Sort (project).ppt
PPTX
6-Python-Recursion PPT.pptx
PPTX
10-SLR parser practice problems-02-06-2023.pptx
PDF
PDF
A* Search Algorithm
PPTX
Java - Generic programming
Bottom up parser
Travelling salesman dynamic programming
Parsing
Quick Sort
Merge sort algorithm
Longest common subsequence
Quick sort algorithn
Types of grammer - TOC
LALR Parser Presentation ppt
daa-unit-3-greedy method
Recursion tree method
Heap Sort (project).ppt
6-Python-Recursion PPT.pptx
10-SLR parser practice problems-02-06-2023.pptx
A* Search Algorithm
Java - Generic programming
Ad

Viewers also liked (11)

PDF
02. divide and conquer
PPT
Presentation on binary search, quick sort, merge sort and problems
PDF
Basic Problems and Solving Algorithms
PPT
Quick sort Algorithm Discussion And Analysis
PPTX
Merge sort and quick sort
PPTX
PPTX
Divide and Conquer - Part 1
PPTX
Divide and conquer - Quick sort
PDF
Quick Sort , Merge Sort , Heap Sort
PPT
Quick Sort
PPT
Algorithm: Quick-Sort
02. divide and conquer
Presentation on binary search, quick sort, merge sort and problems
Basic Problems and Solving Algorithms
Quick sort Algorithm Discussion And Analysis
Merge sort and quick sort
Divide and Conquer - Part 1
Divide and conquer - Quick sort
Quick Sort , Merge Sort , Heap Sort
Quick Sort
Algorithm: Quick-Sort
Ad

Similar to Daa final (20)

PPTX
Mergesort
PPTX
Merge sort analysis and its real time applications
PPT
merge sort help in language C with algorithms
PPTX
10 merge sort
PPTX
DSA- Merge Sort-a sorting technique.pptx
PPTX
Data structure Merge Sort implementation
PDF
merge sort
PPTX
Merge and merge sorting
PPTX
Insertion and merge sort
PPTX
merg sort slide created by anas sanan.pptx
PPTX
8.05.Merge_sort.pptxCUYGYUKTGUIJBJKGKUYGFKJBNVKUYV87VYFHHGVTFGU
PPTX
Merge sort
PPTX
Merge sort algorithm power point presentation
PPTX
Merge sort-algorithm for computer science engineering students
PPTX
Merge sort
PPTX
Merge Sort (w/ principle, algorithm, code, visualizations)
PPTX
dsa presentation on merge sorting in C++.pptx
PPTX
Merge sort
PPTX
MergeSort presentation dgdfgdfgdfgg.pptx
PPT
Merge sort
Mergesort
Merge sort analysis and its real time applications
merge sort help in language C with algorithms
10 merge sort
DSA- Merge Sort-a sorting technique.pptx
Data structure Merge Sort implementation
merge sort
Merge and merge sorting
Insertion and merge sort
merg sort slide created by anas sanan.pptx
8.05.Merge_sort.pptxCUYGYUKTGUIJBJKGKUYGFKJBNVKUYV87VYFHHGVTFGU
Merge sort
Merge sort algorithm power point presentation
Merge sort-algorithm for computer science engineering students
Merge sort
Merge Sort (w/ principle, algorithm, code, visualizations)
dsa presentation on merge sorting in C++.pptx
Merge sort
MergeSort presentation dgdfgdfgdfgg.pptx
Merge sort

Recently uploaded (20)

PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
Trump Administration's workforce development strategy
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PPTX
20th Century Theater, Methods, History.pptx
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PDF
Environmental Education MCQ BD2EE - Share Source.pdf
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
advance database management system book.pdf
DOCX
Cambridge-Practice-Tests-for-IELTS-12.docx
PPTX
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PDF
Uderstanding digital marketing and marketing stratergie for engaging the digi...
PDF
My India Quiz Book_20210205121199924.pdf
Unit 4 Computer Architecture Multicore Processor.pptx
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
Trump Administration's workforce development strategy
Practical Manual AGRO-233 Principles and Practices of Natural Farming
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 2).pdf
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
20th Century Theater, Methods, History.pptx
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
History, Philosophy and sociology of education (1).pptx
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
Environmental Education MCQ BD2EE - Share Source.pdf
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
advance database management system book.pdf
Cambridge-Practice-Tests-for-IELTS-12.docx
ELIAS-SEZIURE AND EPilepsy semmioan session.pptx
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
Share_Module_2_Power_conflict_and_negotiation.pptx
Uderstanding digital marketing and marketing stratergie for engaging the digi...
My India Quiz Book_20210205121199924.pdf

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.