Improved Selection Sort Algorithm
Improved Selection Sort Algorithm
net/publication/272621833
CITATIONS READS
8 7,735
4 authors, including:
Some of the authors of this publication are also working on these related projects:
Designing Algorithm for Malaria Diagnosis Using Fuzzy Logic for Treatment (AMDFLT) in Ghana View project
All content following this page was uploaded by Obed Appiah on 22 February 2015.
29
International Journal of Computer Applications (0975 – 8887)
Volume 110 – No. 5, January 2015
i A=[2, 2, 4, 2, 1, 2, 2, 3, 3, 4, 4, 2,
a 3, 4, 1, 2, 3, 4, 4, 2]
l
-----------------------------------------
------------------------
L
i 1 Pass
s
t A [2, 2, 4, 2, 1, 2, 2, 3, 3, 4, 4, 2,
3, 4, 1, 2, 3, 4, 4, 2]
A 2 2 1 5 2 5 Q [4, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0]
Q Indices 4,14 are added to the
queue
After swapping
1 Pass
A 2 2 1 5 2 5 4 4A [1,5 1, 4,52, 2, 2, 2, 3, 3, 4, 4, 2,
3, 4, 2, 2, 3, 4, 4, 2]
st -----------------------------------------
Q 2 ------------------------
Index 2 added to the queue. 2 Pass
A [1, 1, 4, 2, 2, 2, 2, 3, 3, 4, 4, 2,
3, 4, 2, 2, 3, 4, 4, 2]
2nd Pass
A 1 2 2 5 2 5 Q [3, 4, 5, 6, 11, 14, 15, 19, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
Q 6 7 A [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 4, 4,
3, 4, 3, 3, 3, 4, 4, 4]
Indices 6 and 7 added to the
Q [12, 14, 15, 16, 0, 0, 0, 0, 0, 0,
queue because they all store the
0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
same value as the minimum value
during the third (3rd) Pass. Indices 12, 14, 15, 16 are added
to the queue
4 Pass
th
A 1 2 2 2 4 4 After swapping
A [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3,
3, 3, 4, 4, 4, 4, 4, 4]
Q 6 7 8 9
-----------------------------------------
Indices 6, 7, 8 and 9 added to ------------------------
the queue because they all store
the same value as the minimum
value during the fourth (4th) 4 Pass
Pass. A [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
3, 4, 4, 4, 4, 4, 4]
Sorted List
A 1 2 2 2 4 4 Q [14, 15, 16, 17, 18, 19, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
The list is sorted at the end of the
fourth iteration or pass. The Indices 14, 15, 16, 17, 18, 19 are
existing selection sort will take added to the queue
more time to sort the same list.
After swapping
Another example with original list
A [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3,
as follows
3, 4, 4, 4, 4, 4, 4]
Original List
32
International Journal of Computer Applications (0975 – 8887)
Volume 110 – No. 5, January 2015
3 T=3n O(n)
ji+1
n T = n2 O(n2)
while j<(n)
if Max < A[j]
Max
Rear
If Max = A[j]
Rear
1
Queue[Rear] =
j
//Perform the swapping
of values
Front 0 Figure 1: illustrates the
relationship between
While (Front <= Rear) distinct values in the list
Temp and the run time of the
A[Queue[Front]] ISSA.
33
International Journal of Computer Applications (0975 – 8887)
Volume 110 – No. 5, January 2015
5000 n/4
'40% 499500 250000 383873 498501 299700
n/8
n/16
n/32 499500
'50% 250000 398155 498498 249750
0
4. ANALYSIS OF SS,
OSSA, ESSA,
HSSA AND ISSA
WITH ASAMPLE
DATASET
A given set of data of size 1000 Figure 3: Estimated run times
was finally used to analyse the of various Selection Sort
performances of the various algorithms when input
selection sort algorithms including dataset were not sorted
Improved Selection Sort Algorithm The actual comparison of these
(ISSA). The number of selection sort algorithms could be
redundancies in the set was done when the dataset is
quantified in terms of percentages randomized. Here the
and 11 different sets of values were performance of the improved
used to test the algorithms. The selection sort algorithm (ISSA)
data redundancies in set 1 through recorded best performance when
11 were 0%, 10%, 20%, 30%, the percentages of redundancies
40%,50%, 60%, 70%, 80%, 90%, exceeds 50%
100%. Table 2 illustrates the run
times for the various algorithms on
the various categories of the
5. CONCLUSION
This paper proposed a new
dataset.
selection sort algorithm which
34
International Journal of Computer Applications (0975 – 8887)
Volume 110 – No. 5, January 2015
performs better than the existing [2] Jadoon, S., Solehria, S. F.,
selection sort algorithm and in Qayum, M., “Optimized
most cases may have a run time in Selection Sort Algorithm is
order of O(n) which is ideal for faster than Insertion Sort
sorting relatively large set of data. Algorithm: a Comparative
The strength of the algorithm Study” International Journal
depends on the distinct values in of Electrical & Computer
the list and Sciences IJECS-IJENS Vol:
11 No: 02, 2011
[3] Jadoon, S., Faiz S., Rehman
S., Jan H., “Design &
Analysis of Optimized
Selection Sort Algorithm”,
IJECIJENS Volume 11 Issue
01, 2011.
[4] Khairullah, M. “Enhancing
Worst Sorting Algorithms”.
International Journal of
Advanced Science and
Technology Vol. 56, July,
2013
[5] Kapur, E., Kumar, P. and
Gupta, S., “Proposal of a two
way sorting algorithm and
performance comparison with
existing algorithms”.
International Journal of
Computer Science,
Engineering and Applications
(IJCSEA) Vol.2, No.3, June
2012
[6] “Design and Analysis of
Hybrid Selection Sort
Algorithm”. International
Journal of Applied Research
and Studies (iJARS) ISSN:
2278-9480 Volume 2, Issue
7 (July- 2013) www.ijars.in
IJCATM : www.ijcaonline.org
6. REFERENCES
[1] Cormen, T. H., Leiserson, C.
E., Rivest, R. L., and Stein, C.
2001. Introduction to
Algorithms. MIT Press.
Cambridge. MA. 2nd edition.
2001
35