Improving The Performance of Selection Sort Using A Modified Double-Ended Selection Sorting
Improving The Performance of Selection Sort Using A Modified Double-Ended Selection Sorting
Improving The Performance of Selection Sort Using A Modified Double-Ended Selection Sorting
Web Site: www.ijaiem.org Email: editor@ijaiem.org, editorijaiem@gmail.com Volume 2, Issue 5, May 2013 ISSN 2319 - 4847
Improving the performance of selection sort using a modified double-ended selection sorting
SurenderLakra1, Divya2
1&2
ABSTRACT
Borrowing ideas from single selection sort, we propose a new selection sorting technique for double-ended selection sort. Both theoretical analysis and coding explanation show that the proposed sorting improves the performance of selection sort All the code of elementary sorting techniques are in the textbook, easily found on the web, but the use of double sorting is not available and offer speed improvement over the normal selection sort. With double-ended selection sort, the average number of comparison is slightly reduced. Here, idea of using two chosen elements simultaneously, applies to selection sort, through possibility of enhance speed up 25% to 35%. Code for this sorting is written in dozen lines of C++ Code. So, easily within the reach of beginners who understand the basic concept of this new sorting. In addition, the concept is also cleared more how the N sorts can be improved towards the NlogN sort. However, efforts have been made to improve the performance of selection sorting and implication will be faster.
1. INTRODUCTION
To be a good programmer, an excellent programming practice must be done but this can possible if we know about related topic theoretically as well as practically. In starting when students learn to make program with array, they do exercise relevant to selection sort, and then by the help of required coding convert into code on their own. Many sorting algorithm we did in lab by the help of instructor and over there instructor work was always check students who grabbed the code off the web but effective coding can be possible only when we do own self. Sorting is a data structure operation, which is used for making searching and arranging of element or record. Here arrangement of sorting involves either into ascending or descending order. Everything in this world has some advantage and disadvantage, some sorting algorithms are problem specific means they work well on some specific problem not all the problem. It saves time and help searching data quickly. Sorting algorithm performance varies on which type of data being sorted, not easier to say that which one algorithm is better than another. Here, performance of different algorithm is according to the data being sorted [1]. Examples of some common sorting algorithms are the exchange or bubble sort, the selection sort, the insertion sort and the quick sort. The Selection sort is a good one that use for finding the smallest element in the array and put in the proper place. Swap it with the value in the first position. Repeat until array is sorted (starting at the second position and advancing each time). It is very intuitive and simple to program, offer quit good performance for particular strength being the small number of exchanges needed. The selection sort always goes through a set number of comparisons, for a given no of data items [2]. But sometime question raise in front of us, is there any way through this sorting can be more effective and how to convert that algorithm into code. Then demonstrate a modification of this algorithm, and finally to assign the coding modification as a programming. This paper suggests one simple modification of sorting algorithm: Double Selection Sort. Some one can argue that the use of double sort for these small array partitions will provide a improvement to this critical algorithm. Since the dawn of computing, the sorting problem has attracted a great deal of research, perhaps due to the complexity of solving it efficiently despite its simple, familiar statement. For example, bubble sort was analyzed as early as 1956[3]. Although many consider it a solved problem, useful new sorting algorithms are still being invented (for example, library sort was first published in 2004). Sorting algorithms are prevalent in introductory computer science classes, where the abundance of algorithms for the problem provides a gentle introduction to a variety of core algorithm concepts, such as big O notation, divide and conquer algorithms, data structures, randomized algorithms, best, worst and average case analysis, time-space tradeoffs, and lower bounds. To understand significant concepts and programming practice, a good programming exercise plays an important role i.e. for using double-ended selection sort instead of normal selection sorting technique that enhance the sorting skills. Well, there are two cases occurred at the time of making double sorting code for selection sort, when the size is odd or even. An effort is done in positive direction and realizes coding technique for double sorting offer substantial improvements speed up to 25% to 35% over the single selection sorting [10].
Page 364
Page 365
3. RELATED WORK
Paper such as [11, 12] have worked to address related problems that insertion sort performs better on almost sorted arrays that other O (N) sorting algorithms. In this paper they developed a bi-partitioned insertion algorithm for sorting, which out beats all other O (N) sorting algorithms in general cases and also prove the correctness of the algorithm and give a detailed time complexity analysis of the algorithm. In [12] Ming Zhou, Hongfa Wang suggest an interesting approach to borrow ideas from one- dimensional array selection sorting algorithms, propose a sorting algorithm for two dimensional arrays. Furthermore, conversion of sorting one-dimensional arrays to that of twodimensional (m*n) arrays and find the values of m and n that minimize the computation time. While, [13] Oyelami Olufemi Moses worked on improving the performance of bubble sort using a modified diminishing increment sorting. This paper presents a Meta algorithm called Oyelamis Sort that combines the technique of Bidirectional Bubble Sort with a modified diminishing increment sorting. The results from the implementation of the algorithm compared with Batchers Odd-Even Sort and Batchers Bitonic Sort showed that the algorithm performed better than the two in the worst case scenario. The implication is that the algorithm is faster. Now, the double selection sort problem is a somewhat well-known problem as will be discussed in section 4.
Page 366
Figure 4. Double Selection Sort In figure 4, the part 1 is generated during the first pass with r = 0 and 9, similarly pass 2 , pass3 and pass4 are produced after passing with r =1 and 8, r =2 and 7, r = 3 and 6. From the above representation in Figure 3, it is clear that the algorithm consumes most of its time in the inner loop. During the pass current of the outer loop size current elements are examined to find the smallest remaining elements. This requires size current 1 comparisons. The number of comparisons for all passes is: E(n) Let K = n-index-1 K = n-1 at index = 0 K = 0 at index = n-1 E(n) =n(n-1)/2 = O( ) Selection Sorts find the minimum, or maximum, of N elements in N-1 comparisons. The Max Min algorithm lets you fine the minimum and maximum of N elements in 3N/2 comparisons (keep the current min and max; take 2 more elements, compare them against each other; then compare the two largest and the two smallest). To convert this to a sorting algorithm, we reverse the build direction of the Double Selection Sort algorithm by sorting our array from the outside in. Find the Max & Min in array elements [0..N-1], place them in the two outside positions. Then elements [0 N1], place them in the two outside positions, then iterate this algorithm with the remaining array elements [1 N2]. While Selection Sort requires N /2 + O (N) comparisons, Double Selection Sort will require 3 N /8 + O (N) comparisons, for a 25% speedup on this measure. Unfortunately, Selection Sort is used primarily when comparisons are much cheaper than assignments, since it uses only N + O (1) assignments. Consequently, this improvement does not have as much of the real-life value that Double Selection Sort has. Nevertheless, it could still be a useful assignment, or for a class thats seen Double Selection Sort, it would make a useful comparison and an opportunity to demonstrate the Max Min algorithm. In pseudo code, the double-ended selection sort is described as [9]:
Page 367
Page 368
6. CONCLUSION
Selection Sort is not known to be a good algorithm because it is an in-place comparison sort based sorting algorithm. However, efforts have been made to improve the performance of the algorithm particularly where auxiliary memory is limited. With Bidirectional Selection Sort, the average number of comparisons is slightly reduced and Double Selection sort similar to simple Selection Sort also performs significantly better and carrying out comparisons in a novel way so that no propagation of exchange is necessary. This improvised version of sorting based on using the technique of Double Selection Sort and a modified diminishing increment sorting. The experimentation of the proposed algorithm has shown more efficient instead of using previous version. The algorithm is recommended for all sizes of elements to be sorted but much more efficient as the elements to be sorted increases.
References
[1.] Y.Han Deterministic sorting in O(nlog logn) time and linear space, Proceedings of the thirty fourth annual ACM symposium on Theory of computing , Montreal, Quebec, Canada,2002, p.602-608. [2.] M.Thoroup Randomized Sorting in O(nlog logn) Time and Linear Space Using Addition, shift, and Bit-wise Boolean Operations, Journal of Algorithms, Volume 42, Number 2,February 2002, p.205-230. [3.] Wikipedia. Address: http://www.wikipedia.com [4.] Available at: http://webspace.ship.edu/cawell/Sorting/selintro.htm [5.] Available at: http://www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/Sorting/selectionSort.htm [6.] Availableat:http://72.14.235.104/search?q=cache:oRR7xyvYMJ:linux.wku.edu/~lamonml/algor/sort/ selection.html+selection+sort&hl=en&ct=clnk&cd=3&gl=in, accessed on 20 May, 2007. [7.] Sartaj S (2000). Data Structures, Algorithms and Applications in Java. McGraw-Hill. [8.] Expert Data Structures with C (Third Edition, 2008), R B Patel. [9.] Program Development and Design using C++ (Second Edition), Gary J.Bronson. [10.] Darrah P.Chavey Double Sorting: Testing Their Sorting Skills. [11.] Tarun Tiwari, Sweetesh Singh, Rupesh Srivastava and Neerav Kumar A Bi-partitioned Insertion Algorithm Sorting Motilal Nehru National Institute of Technology, India [12.] Ming Zhou, Hongfa Wang An Efficient Selection Sorting Algorithm for Two-Dimensional Arrays Zhejiang. Water Conservancy and Hydropower College Hangzhou, China [13.] Oyelami Olufemi Moses Improving the performance of bubble sort using a modified diminishing increment sorting Covenant University, P. M. B. 1023, Ota, Ogun State, Nigeria AUTHOR Surender Lakra received the B.Tech and M.Tech. degrees in Computer Science & Engineering from Singhania University, Rajasthan and Amity University, Haryana in 2010 and 2012, respectively. Currently he is working in HIT, Haryana from last one year. He has published Research papers in 2 National/ International Journals and Conferences. His area of interest is Programming Language and Artificial Intelligence.
Page 369
Page 370