(IJCSIS) International Journal of Computer Science and Information Security,Vol. 8, No. 9, December 2010
Pair Wise Sorting: A New Way of Sorting
Md. Jahangir Alam
1, a
, Muhammad Monsur Uddin
2, b
, Mohammad Shabbir Hasan
3, c
, Abdullah Al Mahmood
4, c
E-mail:
1
palash_14@yahoo.com,
2
dolon_it@yahoo.com,
3
shabbir_cse03@yahoo.com,
4
sajibcseofkuet@gmail.com
a.
Dhaka International University, Dhaka, Bangladesh
b.
Institute of Science, Trade and Technology, Dhaka, Bangladesh
c.
Panacea Research Lab, Dhaka, Bangladesh
Abstract
— This paper presents a technique for sorting numericaldata in an efficient way. The numbers of comparisons i.e. therunning time of this technique is dependent on distribution ordiversity of the value of data items as like as other efficientalgorithms. When the total number of data is even, this methodgroups that data into a collection of pairs and thereforeestablishes the sorting constraints on each of the pairs. Thecontrol is traversed through the list of elements by changing theposition of each pair which is the major principle of thistechnique. On the other hand, when the total number of elementsis odd, this method sorts all elements except the last one in thesame was as mentioned earlier and the last element is sortedusing the general Insertion Sort. This algorithm is therefore ahybrid sorting method that sorts elementary numeric data in afaster and efficient manner.
Keywords- Sorting, Pair Wise Sorting, Sorting Techniques.
I.
I
NTRODUCTION
Sorting is a computational building block of fundamentalimportance and is one of the most widely studied algorithmicproblems [1, 2]. The importance of sorting has also lead to thedesign of efficient sorting algorithms for a variety of fieldslike: parallel architectures [3], database systems [4], computergraphics and geographic information systems [5, 6], parallelprogramming patterns [7, 8] and so on. Many algorithms relyon the availability of efficient sorting routines as a basis fortheir own efficiency, and many other algorithms can beconveniently phrased in terms of sorting [9]. It is thereforeimportant to provide efficient sorting routines on practicallyany programming platform.In this paper, we present a new sorting technique which isbased on pair wise comparison. It works separately in twodifferent situations: when total number of elements to besorted is odd and when total number of elements to be sortedis even. This sorting technique has no major efficiencies overother already existing techniques. But its symmetric structuremakes it simpler than other techniques.This paper is organized as follows. Section 2 describes theproposed technique in details, and the paper continues inSection 3 by calculating complexity of the proposed sortingtechnique. Section 4 compares the performance of the proposedtechnique with other already existing sorting techniques. Wefinish by drawing some broad and necessarily speculative andpersonal conclusions and future goal in Section 5.II.
P
ROPOSED
T
ECHNIQUE
-
P
AIR
W
ISE
S
ORTING
The proposed sorting technique works in two differentstrategies depending on whether the number of elements to besorted is odd or even. When the total number of data is even,this method groups that data into a collection of pairs andtherefore establishes the sorting constraints on each of thepairs. The control is traversed through the list of elements bychanging the position of each pair which is the major principleof this technique. On the other hand, when the total number of elements is odd, this method sorts all elements except the lastone in the same was as mentioned earlier and the last elementis sorted using the general Insertion Sort. This sectiondescribes the proposed sorting technique in details.
A.
Working Procedure:
Let an array contains
n
elements where
n
is even. To sortthese elements the proposed technique uses total phaseswhere each phase contains two sub phases. The operationsperformed by two sub phases are different while the functionsof all phases are identical.In the first sub phase the algorithm divides the
n
elementsfrom position 1 to
n
into a total of pairs. The control movesfrom first pair to the last pair and checks whether the firstelement of the pair is larger than the second one and if yes,then these elements are interchanged. In the second sub phase,(
n-2)
elements from position 2 to
(n-1)
are divided unto atotal of
-
1
pairs and the similar checking and swappingoccur as mentioned earlier.An additional check is maintained at the end of each phaseto detect whether any swapping has occurred or not. If nointerchange has been occurred, then the array is declared to besorted and there is no need to continue for further phases.Otherwise, the phases are continued in the similar fashion tillthe final phase. Introduction of this checking may increasecomplexity as it requires initialization, changing and testingduring the phases. But it is very effective for the cases wherelarge numbers of elements are to be sorted and elements areuniformly distributed.This procedure indicates that the number of required phasesis constant for a data set and it is half of the total number of
116http://sites.google.com/site/ijcsis/ISSN 1947-5500