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.
💡 Deep Analysis
📄 Full Content
Sorting Algorithms with Restrictions1
H. Aslanyan
Yerevan State University
1, A. Manoukyan street, 375049 Yerevan
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.
General notes, sorting of binary information
Let it is given a sequence of numbers
n
a
a ,…
1
.An elementary operation
)
:
(
j
i a
a
compares
ia and
ja . Sorting is the reordering of
n
a
a ,…
1
with increasing; - the known boundary of required number of operations
)
(n
S
is known as
∑
=
≤
≤
n
k
k
n
S
n
2
2
2
4
3
log
)
(
!
log
Roughly, the order of given expression is
n
n
2
log
. When the input sequence is ordered and we compare pairs of neighbours, we use
only
1
−
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
a
a ,…
1
and output is its ordered counterpart. The scheme itself is fixed, consisting of 2-comparators linked each to other in
a special way. If
)
(n
S
is the required number of elements of a scheme, then
)
(
)
(
n
S
n
S
≥
and the known estimation is as
)
)
(log
(
)
(
2
2 n
n
O
n
S
. 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
2 1
0 −-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:
1 The research is supported partly by INTAS: 04-77-7173 project, http://www.intas.be
(n-1,3) sorting scheme
The complexity approximation is
4
/
2
n
. Similarly might be constructed an
)
,
(
k
n
scheme of complexity
(
)
∑
∑
∑
=
−
−
−
−
−
−
−
−
−
−
−
−
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 complexity might be reduced. Let us formulate some postulations:
1.
1.
1.
1.
3
S(n,2n/3) =
4
S(n,7n/12) ≤
5
n/2)
S(n,
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
)
(n
L
be complexity of the algorithm for
sorting n elements. The following theorem takes place:
Theorem 2
2
)
log
1(
log
)
(
2
2
n
n
n
L
⋅
≤
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
n
m ≥
. Then it is
possible to merge A and B and obtain a sorted sequence of
n
m +
elements by
)
log(
n
m +
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
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.
è.Ü îáÝáÛ³Ý, ÎáÙµÇݳïáñ ³É·áñÇÃÙÝ»ñ, ԵՊՀ: