Sorting Algorithms with Restrictions
Sorting is one of the most used and well investigated algorithmic problem [1]. Traditional postulation supposes the sorting data archived, and the elementary operation as comparisons of two numbers. In a view of appearance of new processors and appli…
Authors: Hakob Aslanyan
Sorting Algorith ms with Restriction s 1 H. Aslanyan Yerevan State University 1, A. Manoukyan street, 375049 Yerevan 1. Introduction Sorting is one o f the most u sed and well investigated algori th mic p roblem [1]. T raditional postulatio n supposes the so rting data archived, and the elementar y operation as comparisons of two numbers. In a view of appea r ance o f new processo rs and applied problems with data streams, sorting changed its face. This changes and ge neralizations are the subject of investigation in t he research below. 2. General notes, sorting of binary information Let i t is given a sequence of numbers n a a ,... 1 .An elementary operation ) : ( j i a a compares i a and j a . Sorting is the r eordering of n a a ,... 1 with increasing ; - t he kn own boundary of requi red number of ope rations ) ( n S is known as ∑ = ≤ ≤ n k k n S n 2 2 2 4 3 log ) ( ! log Roughly, the order of given ex pression is n n 2 log . When the input sequence is or dered and we co mpare pairs of neighbours, we use only 1 − n comparisons. The e ssential property o f this cla ss of alg orit hms is t he way of selection of cu rrent pair of elements to be compared. There are other algorithms which don’t u se the previous steps. These are special sort ing schemes where input is an y sequence n a a ,... 1 and output is its ordered counte rpart. The scheme itself is f ixed, consis ting of 2-comparators linked each to other in a special way. If ) ( n S is t he required number of elements of a scheme, then ) ( ) ( n S n S ≥ and t he known estimation is as ) ) (log ( ) ( 2 2 n n O n S = . Below a gene ra lization of schemes from 2 to k -comparators will be brought . One more notion is : Theorem 1(the 0-1 principle). If an n -scheme sorts all the n 2 1 0 − - sequences of length n , then it sorts any nume ric sequences of length n . 3. k) (n, Sorting Scheme k) (n, sorting scheme re ceives an n -length inpu t and sorts k elements in one step. Le t us denote th e scheme size by k) S(n, . The simplest (n,3) scheme looks like : 1 The research is suppo rted partly by INTAS: 04-77-7173 proje ct, http://www.intas.be … ( n - 1,3 ) sorting scheme The complexity app roximation is 4 / 2 n . Similarly might be constructed an ) , ( k n scheme of comp lexity ( ) ∑ ∑ ∑ = = − = − − − − − = − − − − = − − n k p n p k p k k k n n p p k k p ) 1 ( 2 ) 2 )( 1 ( ) 1 ( ) 1 ( 1 1 1 1 1 1 1 1 . This complexi ty migh t be reduced. Let us formula te some postulations: 1. 1. 1 . 1. 3 S(n,2n/3) = 2. 2. 2 . 2. 4 S(n,7n/12) ≤ 3. 3. 3 . 3. 5 n/2) S(n, = 4. Parallel Sorting Let’s c onsider an algorithm, which is allowed during each step to perform in parallel ar bitrary number of c ompariso ns of pai r s of elements, with t he on ly restriction – each element occu rs at most i n one compa rison. Let ) ( n L be complexit y of the algo rithm for sorting n elements. The following theore m takes place: Theorem 2 2 2 2 2 ) log 1 ( log ) ( 2 2 n n n L + ⋅ ≤ The proof uses the following prope rty of merge sort algori t hm: Lemma Let A be a decreasing sequence of n elements and B - an incr easing sequence of m elements and n m ≥ . Then it is possible to merge A and B and obtain a sor te d sequenc e of n m + elements by ) log( n m + operations. We skip the proof of t he lemma here. The table below presents the ope rations when we consequently par tition the input sequen ce: Length o f sorted subsequence Number of subsequences Number of ope rations at this stage 1 n 0=0 2 n/2 1=1 4 n/4 log2*2=2 ... ... ... N 1 log(2*n/2)=log(n) 5. References 1. Ñ. äÌÛÚ, àÒÍ ÛÒÒÚ‚Ó ÔÓ„‡ÏÏ ËÓ‚‡ÌËfl, Том 3, Сортировка и поиск, второе издание, 2001 , 832 стр. 2. è.Ü îáÝáÛ³Ý, ÎáÙ µÇݳïáñ ³É·áñÇà ÙÝ»ñ, ԵՊՀ:
Original Paper
Loading high-quality paper...
Comments & Academic Discussion
Loading comments...
Leave a Comment