D.Abhyankar Int. Journal of Engineering Research and Applications www.ijera.com ISSN : 2248-9622, Vol. 4, Issue 4( Version 4), April 2014, pp.131-134 www.ijera.com 131 | Page A Fast Merge Sort D.Abhyankar D. Abhyankar, School of Computer Science, D.A. University, Indore M.P. India Abstract Merge sort is one of the most efficient ways to solve sorting problem. Our research suggests that it is still responsive to clever optimizations. A considerably fast variation of Merge sort has been proposed in this paper. Proposed algorithm uses some novel optimizations to improve the speed of the proposed algorithm. Proposed algorithm not only applies some novel optimizations but also retains most of the old optimizations which were effective in reducing space and time. In addition to time and space efficiency, proposed algorithm offers the benefit of elegant design. Profiling has been carried out to verify the effectiveness of proposed algorithm. Profiling results reinforce the fact that proposed algorithm is significantly faster than existing best algorithm. I. Introduction Sorting is one of the most fascinating computational problems that demands a lot of computer time in practical applications. Merge sort is a stable divide and conquer algorithm that solves sorting efficiently. It requires an extra array of size Θ(n) to sort and thus it is not an in-place sorting algorithm. It spends running time Θ(n log n) to sort the input array [1]. Although a lot of research work has been carried out to improve the performance of Merge sort [2], it is still responsive to novel optimizations. Our research offers a better implementation of Merge sort that saves a lot of time and space. Proposed algorithm provides an extremely compact and fast Merge function. Also, it retains the advantages of existing Merge sort variations. This Section is followed by Section 2 that presents the proposed algorithm. Section 3 presents the comparative profiling statistics of the proposed implementation and the existing best Merge sort. In the end, Section 4 concludes and presents the essence of the paper. II. Proposed Implementation The most novel point in proposed algorithm is the amazingly clever sentinel trick accomplished by making the recursively sorted subarrays overlap. This trick eliminates a test in the inner loop by assuring right side of the array contains the last element. That assurance has a cost: lengthening the first of the two recursive sorts so they overlap. It is important to observe that the trick reduces the code size of Merge function. Actual improvement in terms of time has been assessed by profiling in Section 3. It is important to note that proposed implementation retains the existing optimizations on Merge sort. For instance, proposed implementation is a hybrid of Merge sort and Insertion sort. Also, the data move count has been reduced to an extremely low level. Following C++ code formally asserts the implementation. void Merge(int*& a, int& h, int*& buf); void MergeSort(int* a, int n, int* b, int m); void Copy(int* s, int n, int* d); void InsertionSort(int* a, int n); void Sort(int* a, int n) { if(n > 5) { int h = (n+1)/2; int* b = new int[h+1]; MergeSort(b,h+1,a,1); a[h]=b[h]; MergeSort(&a[h],n-h,a,0); Merge(a,h,b); delete[] b; } else{ RESEARCH ARTICLE OPEN ACCESS