EMS: AN ENHANCED MERGE SORT ALGORITHM BY EARLY CHECKING OF ALREADY SORTED PARTS

  • Mutaz Rasmi Abu Sara Taibah University
  • Mohammad F. J. Klaib
  • Masud Hasan
Keywords: Sorting, Merge sort, Merging, Top-down and bottom-up Merging, Experimental results

Abstract

Merge sort is one of the asymptotically optimal sorting algorithms that is used in many places including programming language library functions and operating systems. In this paper, we give a modified version of merge sort, which in practice shows substantial improvement in running time than the top-down and bottom-up implementations of the classical merge sort. Our algorithm works as a bottom-up manner and the modifications happen in three places: (a) given n elements in an array, first the algorithm considers the array as n / 2 consecutive pairs and sorts each pair in-place by one comparison; (b) in subsequent steps, during the ”merge” process of two subarrays, if the last element in the left subarray is smaller than the first element in the right subarray, the algorithm simply returns; and (c) if the last element in the right subarray is smaller than the first element in the left subarray, then the algorithm swaps the elements in the two subarrays by their entirety. Steps (b) and (c) happen in-place. For the case not in (b) or (c), the algorithm follows the classical merge technique with an extra array. Our experimental results also show that case (b) and (c) happen a good amount of time in practice and that is the reason that our algorithm gives better running time than the classical merge sort.

Published
2020-01-15
How to Cite
Abu Sara, M., Klaib, M., & Hasan, M. (2020). EMS: AN ENHANCED MERGE SORT ALGORITHM BY EARLY CHECKING OF ALREADY SORTED PARTS. International Journal of Software Engineering and Computer Systems, 5(2), 15-25. Retrieved from https://journal.ump.edu.my/ijsecs/article/view/3525