SSorting Algorithms with Restrictions H. Aslanyan
Yerevan State University 1, A. Manoukyan street, 375049 Yerevan
1. Introduction
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 applied problems with data streams, sorting changed its face. This changes and generalizations are the subject of investigation in the research below.
2. General notes, sorting of binary information
Let it is given a sequence of numbers n aa ,... .An elementary operation ):( ji aa compares i a and j a . Sorting is the reordering of n aa ,... with increasing; - the known boundary of required number of operations )( nS is known as ∑ = ≤≤ nk knSn Roughly, the order of given expression is nn log . When the input sequence is ordered and we compare pairs of neighbours, we use only − n comparisons. The essential property of this class of algorithms is the way of selection of current pair of elements to be compared. There are other algorithms which don’t use the previous steps. These are special sorting schemes where input is any sequence n aa ,... and output is its ordered counterpart. The scheme itself is fixed, consisting of 2-comparators linked each to other in a special way. If )( nS is the required number of elements of a scheme, then )()( nSnS ≥ and the known estimation is as ))(log()( nnOnS = . Below a generalization 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 − - sequences of length n , then it sorts any numeric sequences of length n . k)(n, Sorting Scheme k)(n, sorting scheme receives an n-length input and sorts k elements in one step. Let us denote the scheme size by k)S(n, . The simplest (n,3) scheme looks like: … (n-1,3) sorting scheme he complexity approximation is n . Similarly might be constructed an ),( kn scheme of complexity ( ) ∑ ∑ ∑ = = −= − −−−−= −−−−=−− n kp np kp k kknnppkkp )1(2 )2)(1()1()1(11111 . This complexity might be reduced. Let us formulate some postulations: = ≤ =
4. Parallel Sorting
Let’s consider an algorithm, which is allowed during each step to perform in parallel arbitrary number of comparisons of pairs of elements, with the only restriction – each element occurs at most in one comparison. Let )( nL be complexity of the algorithm for sorting n elements. The following theorem takes place: Theorem nnnL +⋅≤ The proof uses the following property of merge sort algorithm:
Lemma
Let A be a decreasing sequence of n elements and B - an increasing sequence of m elements and nm ≥ . Then it is possible to merge A and B and obtain a sorted sequence of nm + elements by )log( nm + operations. We skip the proof of the lemma here.
The table below presents the operations when we consequently partition the input sequence: Length of sorted subsequence
Number of subsequences
Number of operations at this stage n n/2 n/4 log2*2=2 ... ... ... N log(2*n/2)=log(n)
5. References Ñ. äÌÛÚ, àÒÍÛÒÒÚ‚Ó Ô(cid:18)Ó„(cid:18)‡ÏÏË(cid:18)Ó‚‡ÌËfl,