8
Optimized Selection Sort Algorithm for Two Dimensional Array Authors Name/s per 1st Affiliation (Author) Dept. name of organization (Line 1 of Affiliation - optional) Name of organization - acronyms acceptable (line 2) City, Country (line 3) [email protected] – optional (line 4) Authors Name/s per 2nd Affiliation (Author) Dept. name of organization (Line 1 of Affiliation - optional) Name of organization - acronyms acceptable (line 2) City, Country (line 3) [email protected] – optional (line 4) Abstract—The main idea of Optimized Selection Sort Algorithm (OSSA) is based on the already existing selection sort algorithm, with a difference that old selection sort; sorts one element either smallest or largest in a single iteration while optimized selection sort, sorts both the elements at the same time i.e smallest and largest in a single iteration. In this study we have developed a variation of OSSA for two-dimensional array and called it Optimized Selection Sort Algorithms for Two- Dimensional arrays OSSA2D. The hypothetical and experimental analysis revealed that the implementation of the proposed algorithm is easy. The comparison shows that the performance of OSSA2D is better than OSSA by four times and when compared with old Selection Sort algorithm the performance is improved by eight times (i.e if OSSA can sort an array in 100 seconds, OSSA2D can sort it in 24.55 Seconds, and similarly if Selection Sort takes 100 Seconds then OSSA2D take only 12.22 Seconds). This performance is remarkable when the array size is very large. The experiential results also demonstrate that the proposed algorithm has much lower computational complexity than the one dimensional sorting algorithm when the array size is very large. Index TermsAlgorithm analysis, Sorting algorithms, Two Dimensional Arrays, Computational Complexity. INTRODUCTION All Sorting and Searching are the tasks that are repeatedly encountered in various computer applications. Since they reveal basic tasks that must be deal with quite frequently, researchers have tried in the past to develop algorithms efficient in terms of least memory requirement and least time requirement. Searching together with sorting is perhaps the most common operation used in Computing. It was always a matter of great attraction for the researchers that to reduce the time a computer takes in sorting and searching data [1][2]. That's why, the researcher tried to develop speedy, well-organized and economical algorithms for sorting and ordering lists and arrays. This was one of the fundamental fields of research in computing for decades. The development of optimized sorting algorithms will leads to efficient computing as whole. It is observed that, the time to complete the task for most sorting algorithms depends on the amount of data. Consequently to analyze an algorithm, it is required to find a relationship showing how the time needed for the algorithm depends on the

IEEE A4 Format

Embed Size (px)

DESCRIPTION

Paper Format IEEE

Citation preview

Paper Title (use style: paper title)

Optimized Selection Sort Algorithm for Two Dimensional Array

Authors Name/s per 1st Affiliation (Author)Dept. name of organization (Line 1 of Affiliation - optional)Name of organization - acronyms acceptable (line 2)City, Country (line 3)[email protected] optional (line 4)Authors Name/s per 2nd Affiliation (Author)Dept. name of organization (Line 1 of Affiliation - optional)Name of organization - acronyms acceptable (line 2)City, Country (line 3)[email protected] optional (line 4)

AbstractThe main idea of Optimized Selection Sort Algorithm (OSSA) is based on the already existing selection sort algorithm, with a difference that old selection sort; sorts one element either smallest or largest in a single iteration while optimized selection sort, sorts both the elements at the same time i.e smallest and largest in a single iteration. In this study we have developed a variation of OSSA for two-dimensional array and called it Optimized Selection Sort Algorithms for Two-Dimensional arrays OSSA2D. The hypothetical and experimental analysis revealed that the implementation of the proposed algorithm is easy. The comparison shows that the performance of OSSA2D is better than OSSA by four times and when compared with old Selection Sort algorithm the performance is improved by eight times (i.e if OSSA can sort an array in 100 seconds, OSSA2D can sort it in 24.55 Seconds, and similarly if Selection Sort takes 100 Seconds then OSSA2D take only 12.22 Seconds). This performance is remarkable when the array size is very large. The experiential results also demonstrate that the proposed algorithm has much lower computational complexity than the one dimensional sorting algorithm when the array size is very large. Index Terms Algorithm analysis, Sorting algorithms, Two Dimensional Arrays, Computational Complexity.Introduction All Sorting and Searching are the tasks that are repeatedly encountered in various computer applications. Since they reveal basic tasks that must be deal with quite frequently, researchers have tried in the past to develop algorithms efficient in terms of least memory requirement and least time requirement. Searching together with sorting is perhaps the most common operation used in Computing. It was always a matter of great attraction for the researchers that to reduce the time a computer takes in sorting and searching data [1][2].

That's why, the researcher tried to develop speedy, well-organized and economical algorithms for sorting and ordering lists and arrays. This was one of the fundamental fields of research in computing for decades. The development of optimized sorting algorithms will leads to efficient computing as whole. It is observed that, the time to complete the task for most sorting algorithms depends on the amount of data. Consequently to analyze an algorithm, it is required to find a relationship showing how the time needed for the algorithm depends on the amount of data. It is observed that, for an algorithm, when the amount of data is doubled, the time needed is also doubled. Similarly from the analysis of another algorithm it was cleared that when the amount of data is increased the time to complete the task of sorting is increased by a factor of four.

It is also a matter of great concern that, the nature of the data also has an effect on the efficiency of the algorithm. A sorting algorithm may behave differently if the original data set is almost sorted rather than if it is random or it may be in the reverse order.

The creation of spatial data structures that are important in computer graphics and geographic information systems is necessarily a sorting procedure. A well-organized sort routine is also a useful unit in implementing algorithms like sparse matrix multiplication and parallel programming patterns like Map Reduce [3][ 4].

The idea of optimized selection is based on the old selection sort [5]. Unlike the old selection sort which sort data item one at a time, the optimized selection sort algorithm (OSSA) sort two data elements (smallest as well largest) in a single iteration. It reduced the execution time of the selection sort by almost fifty percent, although this algorithm also has a time complexity of [5].

Enormous data in many fields is normally represented by the use of Matrices. It is felt by the computer professional to have efficient sorting algorithms for sorting the two-dimensional arrays. There is plenty of algorithms which mainly focuses on one-dimensional array sorting, but a few algorithms have been proposed for two-dimensional array sorting [6][7]. In [7], the result is extended from one-dimensional array to two-dimensional by the use of interpolation and filtering algorithms which results in a complexity of

Two-dimensional array is treated as one dimensional array by most of the earlier sorting algorithms to sort these elements [8]. Simple selection sorting is the widely sorting algorithm used due to its simplicity and less implementation complexity. Although it has a time complexity of [9] on sorting one dimensional array with elements as comparison operations are required. The time required for sorting large arrays (e.g. arrays with 1000000*1000000 elements) is practically much time consuming.In this article, we propose an optimized sort algorithm for two dimensional arrays, to solve the above mentioned problem of sorting. The hypothetical and experimental results proved that this proposed algorithm has a high efficiency level.

The organization of the paper is as follows. The algorithm is proposed in Section 2. In Section 3 We analyze the proposed algorithm. In Section 4 we present the approach to sorting one-dimensional arrays by the proposed algorithm. Section 5 presents Experimental results. Section 6 contained conclusion.Proposed Optimized selection sort algorithm for two dimensional arraysThe main idea of Optimized Selection sort is based on already existing selection sort algorithm, with a difference that selection sort, sorts one element either smallest or largest in a single iteration while optimized selection sort, sorts the two elements at a time i.e smallest and largest in a single iteration. We have developed a variation of the already existing selection sort for two-dimensional array and called it Optimized Selection Sort Algorithms for Two-Dimensional array.

We have a matrix in the form of as follows

Before going to the stepwise details of the algorithm we will create a new array which will store sorted elements. The working of our proposed optimized selection algorithm for two-dimensional array is depicted in the following steps:

STEP 1: Each row of the array should be sorted using the Optimized Selection Sorting Algorithm (Let assume that the elements are sorted in descending order in each row).STEP2:Initialize the index values of the target array i.e Y such that STEP3:Find the Largest element from the first column and placed it into the successor the largest will now be the first elementof the row.STEP4:Update the index values for STEP5:Goto step (3) if AR is not empty, else goto Exit.STEP6:EXIT.Analysis of OSSA2DThe Most of the time in sorting process the algorithms major cost is on the comparisons of the data items to be sorted. Therefore we analyzed the time complexity of by computing the number of comparison which is performed. As we know for sorting one dimension array the number of comparison required by the selection sort is but we have introduced the OSSA which performs less number of comparisons and it becomes [1]. Let assume that there are rows in a two-dimensional array. So times comparison will be required to sort all the rows of the array.

Now after sorting each row of the array in descending order by the above mechanism we will now search the maximum element in the first column. For this purpose the number of comparison needed is and there are rows and columns. So for all the comparison in the array it needs. After finding the element in the first column it will be transferred to the target array.

Therefore the total number of comparison needed for the two-dimensional array to be sorted using OSSA for two dimensional array will be:

The time complexity for the algorithm after ignoring the constant and lower terms will be:

In [6] the efficiency of old selection sort algorithm for one-dimensional array having the same number of elements as that with the two-dimensional array is found as follows.

For one dimensional array the number of comparison needed by selection sort;

(1)/2 (2)

For two-dimensional array with equal number of elements as that of one-dimensional array the number of comparisons are;

(3)The efficiency Calculated for efficient two dimensional sorting algorithms in [9] is;

Now calculating the efficiency of optimized selection sort algorithm for two-dimensional array, against the efficiency of optimized selection sort for one dimension array;

Again calculating the efficiency of optimized selection sort for two-dimensional array against old selection sort for the same number of data items;

Similarly calculating the efficiency of optimized selection sort of two-dimensional against the efficient selection sort for two-dimensional array; from equation and we have

Now consider if we have the values of and the value of After putting the values in equation (5) and we =

The above result shows that our algorithm is 400 times efficient than the ordinary selection sort for one dimensional array having same amount of data.

if we put the values in the equation (7)

The above result shows that our algorithm is still more efficient than the already existing algorithm for two-dimensional array having same amount of data. Conversion of Single Dimensional Array to Two Dimensional ArrayIt has been observed in the previous section that the sorting of two-dimensional array is far more efficient than the one-dimensional array for the same number of elements. In this section we have tried to convert a one-dimensional array with constant elements to a two-dimensional array having data elements. According to equation (5) we have

And ( )

Since is a constant and > = 1 so according to geometric inequality

SS Algorithm

OSSA

EfSSA

OSSA for 2 Dimensional Array

1000499500249750123991.161995.55

50001249750062487501401714700856.8

10000499950002499750039750001987500

150001.12E+085624625073109693655485

200002E+0899995000112637085631854

When then the values of is the minimum value.

(8)

From the above equation we can calculate the number of comparison of two-dimensional arrays and found that it has the lowest value. As the number of comparison of one-dimensional array is given by , so if the number is increased by 100 times so we need , almost 2500 times more comparisons as that of the two dimensional array which is , 1875 times which is much more less than the previous one OSSA for one dimensional array. We can calculate the values of by the following method.

Some time it might happen that the calculated value of so we need to fill the empty cells of the array with imaginary values depending upon the data to be sorted. If the data is sorted in the descending then we will fill the empty cells with infinitesimal values and with infinite values otherwise.

ResultsAfter The following table shows the number of comparison of one-dimensional array and two-dimensional sorting algorithm.

Table 2. Table showing time consuming of different algorithms

When we plot these results we had;

Figure 1: The plot of Selection Sort and Optimized Selection Sort Algorithm

Figure 2: The plot of Efficient Selection Sort and Optimized Selection Sort Algorithms for 2 Dimensional Algorithms

Figure 3: The plot of OSSA and Optimized Selection Sort Algorithms for 2 Dimensional Algorithms

Figure 4: The plot of Selection Sort and Optimized Selection Sort Algorithms for 2 Dimensional AlgorithmsFrom above graph, one can easily observed that with the increase in number of data elements, the line graph plotted by OSSA is taking less time as compared to graph plotted by Old SS and it will be true for any number of data.Conclusions

It is evident from the above results that optimized selection algorithm for two-dimensional arrays is more efficient than the simple selection sorting algorithm for the same amount of data, and hence proved our claim to be an efficient algorithm of the order of.

References[1] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein.Introduction to Algorithms. MIT Press, Second edition, Sept. 2001.[2] D. E. Knuth. The Art of Computer Programming, Volume 3: Sorting and Searching. Addison-Wesley, Boston, MA,[3] J. Dean and S. Ghemawat. MapReduce: Simplified data processing on large clusters. In Sixth Symposium on Operating System Design and Implementation, Dec. 2004.[4] B. He, W. Fang, N. K. Govindaraju, Q. Luo, and T. Wang. Mars: A MapReduce framework on graphics processors. Technical Report HKUST-CS07-14, Department of Computer Science and Engineering, HKUST, Nov. 2007.[5] Jadoon etal. Design and Analysis of Optimized Selection Sort Algorithm International journal of Electrical and Computer Sciences. 2011, 11(01): p16~p22.[6] Peng Yueying. Quick Sorting Algorithm of Two-dimensional Array. Guangxi Sciences. 1997, 4 (2): p93~p96. [7] Zheng Lian Kai. Method of Sorting Two-dimensional Array Elements. Journal of Liaoning Normal Universit y(Natural Science Edition). 1989(2):p7~p9.[8] Sun Junyi. Two-dimensional array sorting and optimization techniques. Application Research of Computers. 1998(1), p12~p13.[9] Yan Weimin. Data Structure(2nd edition)[M]. Tsinghua University Press, 1992,p264~p293.[10] Ming Zhou, Hongfa Wang. Efficient Selection Sort algorithm for two dimensional array, Fourth International conference on genetic and Evolutionary Computing, 2010.