Proof. In discussed version, algorithm to re-arranging elements in a triple heap
is performed in a loop from i = 0 to i = n − 2. Algorithm to create triple
heap is proceeded n − 1 times. Theorem 1 indicates that height of triple heap
is ⌊log3 n⌋ + 1 and Theorem 2 indicates that time to re-arrange triple heap is
C · n. Algorithm proceeds sorting n−1 times, therefore time complexity can be
estimated as
# (n) = C · (n − 1) · (⌊log3 n⌋ + 1) . (23)
Considering large scale data sets of n elements we can estimate (23) as
# (n) ∼=
C · n · log3 n. (24)
⊓⊔
2.3 Results of examinations
Theoretical analysis of examined versions shows that to find the maximum between
3 elements we compare elements 2 times. Similarly, to find maximum
between 4 elements we compare elements 3 times. Thus, comparing sort times
using double heap sorting to triple heap sorting we estimate potential difference
between those two methods, which is 2·n log2 n
3·n log3 n = 2 log 3
3 log 2 ≈ 1.0566. Therefore proposed
in Section 2 triple heap sort algorithm should be theoretically 5% more
effective. To verify this conclusion we have compared results of numerical experiments.
Described algorithm was examined for large scale data sets. Algorithm
was implemented using CLR C++ in MS Visual Studio 2010 Ultimate. To test
were taken random samples of 100 series in each class of frequencies, including
unfavorable positioning. Tests were carried out on quad core amd opteron processor
8356 8p. Research results were plotted in Fig.2 and Fig.3. The speed of
performed operations depends on the initial arrangement of the input data. It
is also affected by the number of changes made at a constant number of comparisons.
The aim of the analysis and comparison is to verify if the extended
triple heap is really better to sort large data sets than the classic version. In the
examinations and tests were compared the characteristics of the proposed algorithm
with the classic version. The analysis of Fig.2 shows that the proposed
algorithm behaves similarly to the classic version. In the interval to 1000000
elements, proposed in Section 2 algorithm can increase the stability of sorting
procedure. The values of the coefficients of variation are presented in Table 1.
Coefficients of variation were plotted with polynomial approximation, which is
shown in Fig.3. The resulting curves characterize potential variability of the examined
versions. Analysis of Fig.3 shows that the greatest variation of stability
of the classic version occurs in the area of 1000000 elements. The version that
uses triple heap has a better stability, understood as the repeatability of the
achieved results. Therefore, the application of the heap with extended structure
has a positive effect on sorting. Illustration of the difference between the two examined
versions of the algorithm is shown in Fig.3. As the reference method was
taken classic algorithm. The analysis and comparison of charts in Fig.3 shows