Rigorous Design of an Efficient Merge Sort K. P. Singh, L. P. Singh and Manish kumar
Asst. Prof. Prateek Srivastava
Computer Science Department Hindustan College of Sci. & Technology Mathura, (U.P) India
[email protected],
[email protected],
[email protected]
Computer Science Department Hindustan College of Sci. & Technology Mathura, (U.P) India
[email protected]
Abstract²Sorting is the crucial work in the field of computing. There are many sorting algorithm but only few algorithm utilize presortedness in input. If we utilize the presortedness than the efficiency of algorithm dramatically increase. In this paper we have presented a work on merge sort, That results to an adaptive sorting algorithm. Adaptive Sorting Algorithm utilizes the presortedness present in the input sequence. Our algorithm check the sequence whether it is sorted or not before partition. Theoretical analysis show that new algorithm perform better then merge sort. Experiment results show that it significantly reduce the sorting time. Keywords-Adaptive sorting, Disorder
I.
INTRODUCTION
Sorting is the computational process of rearranging the given sequence of item into ascending or descending order [1]. It well known statement that any comparison based sorting algorithm optimally take Ĭ(n lg n) time. We cannot do better than optimal in comparison based sorting algorithm. However, if sorting algorithm takes advantage of presortedness present in the sequence than the sorting time lies between Ĭ(n) to Ĭ(n lg n) as the size and disorder present in the input sequence. Adaptive sorting are useful because nearly sorted sequences are common in practice than we have possibility to improve an algorithm that are obvious to the existing order [2]. In this paper we present a scheme that take the advantage of present presortedness in the sequence so the performance of sorting improves. We use step-down runs in the measure of disorder and assume that all the element in the given sequence have distinct values. II.
PREVIOUS WORK
Earliest literature in this field is that of W.H Burge [5]. In "sorting tree and measures of disorder", he claims that sorting algorithm perform best if we take into account the pre-existing order of data. He also proposed measure of disorder to evaluate the existing order. Initial research on adaptive sorting algorithms concentrated on internal sorting algorithms and followed three directions.
First, during 1977 -1980, data structures were designed to represent sorted sequences and provide fast insertions for elements whose position was close to the position of previous insertions. Different adaptive variants of insertion-based sorting algorithms were obtained by using these data structures to maintain the sorted portion of the sequence [6]. Second, [7] and Wainwright in 1985 performed empirical studies. Third, [8] introduced Smooth Sort in 1982. The intuitive ideas arising from these efforts were formalized by [9] who, in 1985, introduced a formal framework for the analysis of adaptive sorting algorithms in the worst case [9]. This framework consists of two parts: First, the introduction of the concept of a measure of presortedness as a function that evaluates disorder; Second, the concept of optimal adaptivity of an algorithm with respect to a measure of presortedness. Because of the developments of Petersson [10], adaptive sorting algorithms are now well understood [2]. Estivill-Castro and Derick Wood conducted a series of work on adaptive sorting. Their work includes the development of generic adaptive sorting algorithm that focuses on the combinatorial properties of measures of disorder rather than the combinatorial properties of the algorithm [1] and [2]. The scheme is developed for both fixed and variable partitioning. Using them they obtained practical adaptive sorting algorithms optimal with respect to several important measures of disorder. They also introduced randomized generic sort, where partitions in a given sequence are created by a randomized division protocol [3]. III.
MEASURE OF DISORDER
We use step-down runs as the measure of disorder. We calculate the disorder for the given sequence in following way [1]. A. Determination of disorder In step-down runs the disorder is measured by the number of consecutive inverse. Specifically the disorder M(X) of a sequence X is measured as below. Let X = given permutation of sequence.
Proc. of the International Conference on Advanced Computing and Communication Technologies (ACCT 2011) Copyright © 2011 RG Education Society ISBN: 978-981-08-7932-7 438
be a
Proc. of the International Conference on Advanced Computing and Communication Technologies (ACCT 2011)
ȁȁିଵ
ĬQOJQ UXQQLQJWLPH [4]. But in our algorithm MSE check the presortedness just before the key step of merging if there is runV WKHQLWVLPSO\WDNHVĬQ +HQFHZHVD\WKDW, this DOJRULWKPOLHVEHWZHHQĬQ WRĬQOJQ )RUVWDWLVWLFDOO\ analysis we also enclosed a cooperative time taken table between merge sort and our MSE algorithm.
ܯሺܺሻ ൌ ݅ܥ ୀଵ
Where Ci = 1 If Xi >Xi-1 and Ci = 0 If Xi