this is all about the merge sort which is basically the part of the searching and sorting
Size: 77.52 KB
Language: en
Added: Oct 14, 2018
Slides: 13 pages
Slide Content
PRESENTATION ON MERGE SORT 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.