here is my presentation of Merge and Merge sorting a topic from Data Structure and Algorithm. I hope this will be easy to understand and informative for you.
Harnessing the Power of GenAI for BI and Reporting.pptx
Merge and merge sorting
1. Merge and Merge Sorting
Presentation
Presented By:
Sania Rana
2. Merge Sort:
It is invented by John Von Neumann (1903-1957).
A sorting technique based on divide and conquer technique. With
worst case complexity being O(n log n), it is one of the most respected
algorithms.
Merge sort first divides the array into equal halves and then combines
them in a sorted manner.
3. Divide and Conquer:
Merge Sort
Divide
Conquer
►Divide: Divide the unsorted list into two sub-lists of about half the size.
►Conquer: Sort each of the two sub-list recursively until we have list sizes of length 1, in
which case the list itself is returned.
►Combine: Merge the two sorted sub-lists back into one sorted list.
4. Merge sort
algorithm of array
ARR contains N
elements:
START
IF array ARR has only one element, it’s
already sorted, THEN
EXIT
ELSE
Divide the array recursively into two
halves until it cannot be further divided.
END IF
Merge the smaller sub-arrays into new
array in sorted order
EXIT
5. Merge sort example:
Consider a sequence of numbers
7, 2, 9, 4, 3, 8, 6, 1
Divide the Array into two parts
7, 2, 9, 4 | 3, 8, 6, 1
6. Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7,2 | 9,4
► Divide the Array into two parts again.
7. Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7, 2 | 9, 4
7 | 2
► Break each element into single part.
8. Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7, 2 | 9, 4
7 | 2
7
► Sort the elements from smallest to largest.
9. Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7, 2 | 9, 4
7 | 2
7
2
►Sort the elements from smallest to largest.
10. Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7, 2 | 9, 4
7|2 2 7
7
2
► Sort the elements from smallest to largest.
11. Merge sort example:
7, 2, 9, 4 | 3, 8, 6, 1
7, 2 | 9, 4
7|2 2 7
7
2
9|4 4 9
9
4
► Sort the elements from smallest to largest.