International Scholarly Research Notices

International Scholarly Research Notices / 2012 / Article

Research Article | Open Access

Volume 2012 |Article ID 947634 | 5 pages | https://doi.org/10.5402/2012/947634

The Middle Pivot Element Algorithm

Academic Editor: Q.-W. Wang
Received07 Nov 2012
Accepted29 Nov 2012
Published31 Dec 2012

Abstract

This paper is an improvement over the previous work on New Sorting Algorithm first proposed by Sundararajan and Chakraborty (2007). Here we have taken the pivot element as the middle element of the array. We call this improved version Middle Pivot Element Algorithm (MPA) and it is found that MPA is much faster than the two algorithms RPA (Random Pivot element Algorithm) and FPA (First Pivot element Algorithm) in which the pivot element was selected either randomly or as the first element, respectively.

1. Introduction

One of the computational problems that an algorithm encounters is due to the multiple input parameters that has a direct effect on the execution time of the algorithm and we call this problem as one of parameterized complexity of the algorithm. In the recent past much of the work has been done to simulate the parameterized complexity of an algorithm under different situations. The present work is an improvement on the previous works by Sundararajan and Chakraborty [1] in which the New Sorting Algorithm was introduced. In order to make this paper self-contained, we are providing it again.

Step 1. Initialize the first element of the array as a pivot element.

Step 2. Starting from the second element, compare it to the pivot element.

Substep 1. If pivot < element then place the element in the last unfilled position of the temporary array (of same size as the original one).

Substep 2. If pivot ≥ element then place the element in the first unfilled position of the temporary array.

Step 3. Repeat Step 2 till the last element of the array.

Step 4. Finally place the pivot element in the blank position of the temporary array. (Remark: the blank position is created because one element of the original array was taken out as pivot).

Step 5. Split the array into two, based on the pivot element’s position.

Step 6. Repeat Steps 15 till the array is sorted completely.

Prashant et al. [2], Anchala and Chakraborty [3, 4], and a recent unpublished paper by the present authors entitled “Parameterized Complexity: A Statistical Approach Combining Factorial Experiments with Principal Component Analysis.” are some of the related works. This last paper compares the parameterized complexity of two algorithms called the RPA (Random Pivot element Algorithm) and FPA (First Pivot element algorithm) in respect to the new sorting technique developed by Sundararajan and Chakraborty [1]. In this paper we have taken the pivot element as the middle term of the array in new sorting technique and call this algorithm MPA (Middle Pivot element algorithm). Thus Step 1 in MPA should be read as follows.

Step 1. Initialize the middle element of the array as a pivot element.

The rest of the steps are the same as above.

The paper reveals two interesting features: (i) MPA is much faster than RPA and FPA and (ii) MPA is more efficient in sorting a large number of elements than what can be sorted by RPA and FPA. See Mahmoud [5] for a comprehensive literature on sorting with special emphasis on distribution theory.

2. Statistical Analysis of the MPA Algorithm

A 3-cube factorial experiment is employed to examine the singular and nonsingular effects of binomial inputs on the complexity. The three factors are (i) , the numbers to be sorted, and (ii) , and (iii) , the two parameters of the binomial ( , ) distribution. The three factors and their levels are given in Table 1.


Factorlevel

100001500020000
100150200
0.20.50.8

Five runs for each of the 27 treatment combinations were made and execution time was obtained using Visual C++ code.

A 3-cube factorial experiment was conducted and analyzed using MINITAB 16 and the results are given below in Table 2. As there are five runs, so there will be replicates with degrees of freedom. The significant points of the variance ratio statistic are compared in Table 3.


SourceDFSeq SSAdj SSAdj MS p-value

40.000390.000390.000101.150.336
220.8906120.8906110.44531 0.000
20.156240.156240.07812927.460.000
20.023590.023590.01179140.010.000
40.027210.027210.0068080.760.000
40.003550.003550.0008910.530.000
40.000620.000620.000161.840.127
80.002230.002230.000283.310.002
Error1040.008760.008760.00008

Total13421.11319


FactorsRPAFPAMPA

233.21180.35927.46
35.20128.57140.61
435.5213.8210.53
9.5442.0380.76
263.8334.191.84

The interesting and important points to be noted from Table 4 are that irrespective of any value of , , and the sorting time is much smaller for MPA as compared to the other two algorithms RPA and FPA. In other words the New Sorting technique with pivot element as the middle element is faster and should be preferred.


RPA

501001505010015050100150

10000.5094.4970.4248.4904.5186.4236.4716.4750.4524
15000.95161.056.91881.4081.1658.98121.13741.0661.159
200001.87 21.8661.8731.9031.8781.6061.6111.6561.753

FPA

501001505010015050100150

5000.1750.1628.1596.1842.1658.1586.1906.1816.1720
10000.4752.4560.3972.4816.4376.4438.5218.5252.4748
15000.9876.9592.8278.9718.9404.91701.0874.87781.006

MPA

501001505010015050100150

10000.406.3810.3576.3908.3690.3436.4062.3998.3876
15000.8282.7750.7440.8096.7470.7188.8314.7690.7436
200001.4221.3441.30001.37821.29341.2721.42201.33921.2968

A systematic pattern is observed for changing the binomial parameters [2]. For fixed and fixed , the sorting time shows a decreasing trend in response to an increase in . While for fixed and , the sorting time is minimum at . At , the sorting time is less than or equal to the same at ; while in the other two algorithms, for fixed , the sorting time responds in a very erratic way, for example, when we change keeping fixed or change keeping fixed in RPA. On the other hand, in FPA for fixed and fixed , the sorting time shows almost decreasing trend while the probability points are increased. However, for fixed and , no systematic pattern is found in the time value corresponding to the change in the value of .

Now we study the behavior of the three factors separately on sorting time, in seconds, by observing -time, -time, and -time plots.

(1) -Time Plot
-time plots show that average time complexity can well be explained by a second degree polynomial with a value of . We may conclude that experimentally the complexity supports an O( ) complexity (See Figure 1).

(2) -Time Plot
From Figure 2 it is clear that complexity is of O( ).

(3) -Time Plot
From Figure 3 sorting time is of O( ).

We may conclude that as far as the singular inputs are considered, the experimental complexity can be well explained by second-degree polynomial in for each of the binomial inputs.

To make further investigations a second-degree composite response surface design was fitted using MINITAB statistical package and the results are given in Table 5.


SourceDFSeq SSAdj SSAdj MS -value

Regression93.979913.979910.44221 178.570.000
 Linear33.167993.167991.05600426.430.000
 Square30.808640.808640.26955108.850.000
Interaction30.003280.003280.00109 0.440.730
Residual error 80.019810.019810.00248
Lack-of-fit 50.019810.019810.00396**
Pure error30.00000 0.000000.00000

Total173.99972

R-Sq = 99.5%.
A high value of reveals that a second degree response surface design can be fitted to represent time as functions of input parameters.
An approximate model is given as
time = .378 + .284 −.032 + .011 + .071 + .057 + .053 .

The Contour plots for different pairs are as given below.

(1) - Plot
The minimum response is found in the middle and the highest response is near the upper left corner (See Figure 4).

(2) - Plot
Minimum time of .7 seconds occurs near middle and goes up to 22 seconds when is held at middle point (See Figure 5).

(3) - Plot
At , minimum time of .7 seconds increases to 22 seconds which occurs in the lower right corner (See Figure 6).

For a target response of 1 second, the optimal solution is , and minimum time is ; minimum sorting time is .43 seconds.

Remark
Capital letter , indicates the probability of success in a trial for the Binomial variate and should not be confused with the small letter of -value in in Tables 2 and 5 which gives the smallest value of level of significance at which a test statistic (here the statistic) becomes significant. Level of significance is the probability of committing type I error, i.e., the probability of rejecting the null hypothesis when it is true.Thus both and represent two different probabilities.

Further results obtained are as follows:Condition number: ; -optimality (average leverage): 0.5000;Maximum leverage: 0.5946.

3. Conclusion

As the New Sorting method is concerned the pivot element as the middle element is preferable to the pivot element being the first and also the same being randomly selected. Also the new sorting technique with middle element as the pivot element is more efficient in the sense that it can sort a large number of elements. However, when compared with Quick sort for the same number of observations to be sorted, the latter is found to be faster. Our future work is to improve the method by deleting the auxiliary array which may further reduce the sorting time as well as save space complexity.

References

  1. K. K. Sundararajan and S. Chakraborty, “A new sorting algorithm,” Applied Mathematics and Computation, vol. 188, no. 1, pp. 1037–1041, 2007. View at: Publisher Site | Google Scholar
  2. P. Kumar, A. Kumari, and S. Chakraborty, “Parameterized complexity on a new sorting algorithm: a study in simulation, annals,” Annals Computer Science Series, vol. 8, no. 2, pp. 9–22, 2009. View at: Google Scholar
  3. A. Kumari and S. Chakraborty, “Software complexity: a statistical case study through insertion sort,” Applied Mathematics and Computation, vol. 190, no. 1, pp. 40–50, 2007. View at: Publisher Site | Google Scholar
  4. A. Kumari and S. Chakarborty, “A simulation study on quick sort parameterized complexity using response surface design,” International Journal of Mathematical Modeling, Simulation and Applications, vol. 1, no. 4, pp. 448–458, 2008. View at: Google Scholar
  5. H. Mahmoud, Sorting: A Distribution Theory, John Wiley Sons, 2000.

Copyright © 2012 Anchala Kumari and Soubhik Chakraborty. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.

3840 Views | 431 Downloads | 0 Citations
 PDF  Download Citation  Citation
 Download other formatsMore
 Order printed copiesOrder

We are committed to sharing findings related to COVID-19 as quickly and safely as possible. Any author submitting a COVID-19 paper should notify us at help@hindawi.com to ensure their research is fast-tracked and made available on a preprint server as soon as possible. We will be providing unlimited waivers of publication charges for accepted articles related to COVID-19.