Você está na página 1de 7

International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),

ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 10-16 IAEME
10











AN EFFICIENT SORTING ALGORITHM: INCRECOMPARISION SORT


Ms. Geeta
1
, Ms. AnubhootiPapola
2

1
M.Tech, 2
nd
year, Dept. Computer Science and Engineering,
Uttarakhand Technical University, India
2
Assistant Professor, Dept. Computer Science and Engineering,
Uttarakhand Technical University, India


ABSTRACT

Data Structure is a logical organization of data which subsume of a number of operations,
sorting is one of them. Sorting facilitate some other operation such as searching, merging and
normalization.[6] There are many sorting algorithm that has being used in practical life as well as in
computation. A sorting algorithm includes comparison, swapping, and assignment operations. There
are numerous of the sorting algorithm like Selection Sort, Double Ended Selection Sort, Max-Min
Sort which takes O(n
2
) time in its best case and perform unnecessary number of
comparisons.[2,3,4,9] In this paper we proposed an algorithm Increcomparision Sort (ICS) which
does not execute unnecessary number of comparisons. This paper shows enhancement of those
algorithm which has complexity n
2
in their best case.

Keywords: Algorithm, Max-Min Sort, Double-Ended Selection Sort, Complexity, Increcomparision
Sort.

INTRODUCTION

An algorithm is an effective method expressed as a finite list of well-defined instructions for
calculating a function In this computational world, sorting plays an important role. Sorting is an
arrangement of data items either in

1. Statistical Order:- Order the data based on their numerical values. This is performed in the
form-
a) Ascending Order:- Smallest item is in first place and largest item is in last place. Or we
can say smallest item sorted first.
b) Descending Order:- Largest item is in first place and smallest item is in last place. Or we
can say largest item sorted first.
INTERNATIONAL JOURNAL OF ADVANCED RESEARCH IN ENGINEERING
AND TECHNOLOGY (IJARET)


ISSN 0976 - 6480 (Print)
ISSN 0976 - 6499 (Online)
Volume 5, Issue 9, September (2014), pp. 10-16
IAEME: www.iaeme.com/ IJARET.asp
Journal Impact Factor (2014): 7.8273 (Calculated by GISI)
www.jifactor.com

IJARET
I A E M E
International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 10-16 IAEME
11

2. Lexicographical Order:-Alphabetical value like addressee key
There are many well known sorting algorithms for unsorted list, such as selection sort, Quick
sort, Insertion sort, Merge sort, Bubble sort and so on. There are many factors to evaluate the
performance of the sorting algorithms which are given below. [1]

1. Computational complexity (worst, average and best behavior) (n).
2. Usage of memory and other computer resources.
3. Stability
4. Number of swaps (for in-place algorithms).
5. Number of comparisons

The common sorting algorithms can be divided into two classes by the difficulty of their
algorithms. There is a direct correlation between the complexity of an algorithm and its relative
effectiveness. Complexity of an algorithm is calculated by asymptotic notations and in three cases.
There are three types of asymptotic notations-

1. O notation:- O(g(n)) = { f(n) : positive constants c and n
0,
such that n n
0
, we have
0 f(n) cg(n) }

2. notation:- (g(n)) = { f(n) : positive constants c
1
, c
2
, and n
0,
such that n n
0
, We have
0 c
1
g(n) f(n) c
2
g(n) }

3. -notation: (g(n))={ f(n): positive constants c and n
0,
such that n n
0
, we have
0 cg(n) f(n) }

The three cases are-

1. Best case:- minimum time taken by an algorithm.
2. Average case:- average time or mean time taken by an algorithm.
3. Worst Case:- Maximum time taken by an algorithm.

Double ended selection sort and max-min sort perform unnecessary comparisons and swaps
in case of sorted array. To improve this we proposed an algorithm in which there is no need of
unnecessary swaps which improve the complexity of algorithm.

Increcomparision Sort:- Sorting is one of the profound research area. For any sorting algorithm its
minimum complexity shows its good performance. Increcomparision Sort does not perform
nonessential number of comparisons in its best case. Increcomparision Sort comprises the steps-

1. i=0;
2. while(i<n-1)
3. if(a[i]<=a[i+1])
4. i=i+1;
5. else count++;
6. for j=n-1to 0
7. if(a[j]<a[j-1])
8. exchange a[j] to a[j-1];
11. else
12. if(i=j) or (count=j)
13. break;
14. i++;

In this algorithm first we initialize i as 0. n is number of element in given array.
International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 10-16 IAEME
12

Working of Increcomparision Sort:- In this sorting algorithm it is based on value of array
whether simply increase the index value or swap the array value. If the previous array value less than
next one, we simply increase the index value .otherwise start swapping from backward.

Suppose we have an array A which have 8 elements.

1 2 3 8 7 6 4 5

After 1
st
iteration

1 2 3 8 7 6 4 5

After 2
nd
iteration

1 2 3 8 7 6 4 5

After 3
rd
iteration

1 2 3 8 7 6 4 5

After 4
th
iteration

1 2 3 4 8 7 6 5

After 5
th
iteration

1 2 3 4 5 8 7 6

After 6
th
iteration

1 2 3 4 5 6 8 7

After 7
th
iteration

1 2 3 4 5 6 8 7

The sorted array is

1 2 3 4 5 6 8 7

Fig 1: Working of Increcomparision Sort

International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 10-16 IAEME
13

Complexity of Increcomparision Sort:-Complexity of any algorithm is represents as - Time
Complexity, which calculates time taken by any algorithm where as Sapce complexity defines, how
much space or memory required for any algorithm.

Table 1: Complexity of Increcomparision Sort
Algorithm Cost Time
i=0 C1 1
while(i<n-1) C2 n
if(a[i]<a[i+1]) C3 n-1
i=i+1 C4 (n-1).ti
else count++ C5 te
for j=n-1 to 0 C6 te.n
if(a[j]<a[j-1]) C7 te.(n-1)
exchange a[j] to a[j-1] C8 te.(n-1). tj
Else if(count=j) or(i=j) C9 tee
break; C10 tee.t
ci
i++ C11 te

In above table cost defines a constant amount of time is required to execute each line of our
algorithm. One line may take a different amount of time than another line but we shall assume that
each execution of the i
th
line takes time c
i
, where c
i
is a constant. Time defines how much time each
line executes in the given algorithm.[16] We can say complexity of any algorithm is sum of
multiplication of cost with time of each line.

Complexity of Algorithm
T(n)= C1*1+C2*n+C3*(n-1)+C4*(n-1).ti+ C5*te+C6* te.n+C7* te.(n-1)+C8*te.(n-1).tj+ C9*
tee+C10* tee.t
ci
+C11* te

Where
t
e
=(n-1)-(n-1). t
i
tee= t
e
.(n-1)-t
e
.(n-1).t
j

t
i
=1 if condition is true otherwise 0.
Similarly,
tj,tci=1 if condition is true otherwise 0.

In Best case:-
t
e
=0 and ti=1so

T(n)=C1.1+C2.n+C3.(n-1)+ C4.(n-1)+ C5.0+ C6.0+ C7.0+ C8.0+ C9.0+ C10.0+ C11.0
T(n)=C1 + nC2 + nC3 C3 + nC4 -
C4
T(n)= n(C2 + C3+ C4 ) (C3+C4) + C1


International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 10-16 IAEME
14

So complexity in best case
T(n)=O(n)

In Worst case:-
ti=0 and t
e
=n-1

T(n)=C1*1+C2*n+C3*n-1+C4*(n-1).0+ C5*(n-1)+ C6*(n-1).n +C7* (n-1)(n-1) +C8. (n-1).(n-
1).t
j
+C9*(n-1).(n-1).t
j
+C10.((n-1).(n-1)-(n-1)(n-1).t
j
)t
ci
+C11.(n-1)
For the worst case complexity of any algorithm depends on its inner most loop. In this sorting
algorithm complexity is depends on C6*(n-1)n .
So worst case complexity
T(n)=O(n
2
)

Comparison With other algorithm:- Increcomparision sort takes minimum time in its best case. It
is better than selection sort, merge sort, heap sort etc. in its best case . But in its worst case it also
produces O(n
2
) time like some other algorithms insertion sort, cocktail sort.[7,8]

Table 2: Comparison with different sorting algorithms
Algorithm Best Case Average Case Worst Case
Selection Sort O(n
2
) O(n
2
) O(n
2
)
Bubble Sort O(n
2
) O(n
2
) O(n
2
)
Insertion Sort O(n) O(n
2
) O(n
2
)
Merge Sort O(nlogn) O(nlogn) O(nlogn)
Heap Sort O(nlogn) O(nlogn) O(nlogn)
Quick Sort O(nlogn) O(nlogn) O(n
2
)
Cocktail Sort O(n) O(n
2
) O(n
2
)
Max Min Sort O(n
2
) O(n
2
) O(n
2
)
Double Ended Selection Sort O(n
2
) O(n
2
) O(n
2
)
Increcomparision Sort O(n) O(n
2
) O(n
2
)

CONCLUSION AND FUTURE SCOPE

In computer science, a sorting is an efficient way which is used to puts elements of a list in a
certain order or arranges a collection of items into a particular order. Sorting data has been developed
to arrange the array values in various ways for a database. In this paper we introduce the
Increcomparision sort, how it is work, what its complexity and how better it is than other algorithms.
Increcomparision Sort is an algorithm which is good for small amount of data. It produces faster
result on that data and it is easy to understand for everyone. It is a straightforward approach and has
a lot of future scope. Sorting algorithm based on divide and conquers approach produces very fast
result. Most of these algorithm takes O(nlogn) time. So there is a chance we can improve
Increcomparision Sort. We can employ this approach in Quick Sort to improve its worst case
complexity in case when array is already sorted. This approach is problem oriented so it is a
possibility to make it global oriented. This algorithm is implemented using static data structure, so it
may be prospect we will implement using dynamic data structure.
International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 10-16 IAEME
15

At last we want to say there is a vast scope of sorting algorithm in future and to find an
optimal sorting algorithm in future.

REFERENCES

[1] Mrs. P. Sumathi, Mr. V. V. Karthikeyan, A New Approach for Selection Sorting,
In International Journal of Advanced Research in Computer Engineering & Technology
(IJARCET) Volume 2, Issue 10, October 2013.
[2] Md. Khairullah Enhancing Worst Sorting Algorithms, In International Journal of
Advanced Science and Technology Vol. 56, July 2013.
[3] Aayush Agarwal,Vikash Pardesi ,Namita Agarwal, A new Approach to Sorting: Min-Max
Sorting Algorithms, In International Journal of Engineering Research and Technology,
May 2013.
[4] Surender Lakra, Divya, Improving the performance of selection sort using a modified
double-ended selection sorting, In International Journal of Application or Innovation in
Engineering & Management, May 2013.
[5] Surmeet Kaur, Tarundeep Singh Sodhi, Parveen Kumar, Enhanced Insertion Sort
Algorithm, In International Journal of Computer Applications, Volume 64 No.21,
February 2013.
[6] Oyelami Olufemi Moses, Bidirectional Bubble Sort Approach to Improving the
Performance of Introsort in the Worst Case for Large Input Size, In International
Journal of Experimental Algorithms (IJEA), Volume (4) : Issue (2), 2013.
[7] D.T.V Dharmajee Rao,B.Ramesh, Experimental Based Selection of Best Sorting
Algorithm , In International Journal of Modern Engineering Research, July 2012.
[8] Surmeet Kaur, Tarundeep Singh Sodhi, Parveen Kumar, Freezing Sort, In International
Journal of Applied Information Systems (IJAIS) Volume 2 No.4, May 2012.
[9] E. Kapur, P. Kumar and S. Gupta, Proposal of a two way sorting algorithm and
performance comparison with existing algorithms, In International Journal of Computer
Science, Engineering and Applications (IJCSEA), vol. 2, no. 3, (2012).
[10] V. Mansotra and Kr. Sourabh Implementing Bubble Sort Using a New Approach, In
Proceedings of the 5th National Conference; INDIACom-2011, March 10 11, 2011.
[11] Sultanullah Jadoon , Salman Faiz Solehria, Prof. Dr. Salim ur Rehman, Prof. Hamid Jan ,
Design and Analysis of Optimized Selection Sort Algorithm, In International Journal of
Electric & Computer Sciences IJECS-IJENS Vol: 11 No: 01, February 2011.
[12] S. Chand, T. Chaudhary and R. Parveen, Upgraded Selection Sort, In International
Journal on Computer Science and Engineering (IJCSE), ISSN: 0975-3397, vol. 3, no. 4,
2011.
[13] Jehad Alnihoud and Rami Mansi, An Enhancement of Major Sorting Algorithms, In
The International Arab Journal of Information Technology, Vol. 7, No. 1, January 2010.
[14] Dr. D. E. Knuth, The Art of Computer Programming, 3rd volume, "Sorting and Searching,
second edition.
[15] E. Horowitz, S. Sahni and S. Rajasekaran, Computer Algorithms, Galgotia Publications.
[16] Introduction to Algorithm, Thomas H. Coremen, Charles E. Leiserson, Ronald L. Rivest,
Clifford Stein, Page no 23-39.
[17] http://en.wikipedia.org/wiki/Sort ing_algorithm.
[18] http:// www.algolist.net/ Algorithms/ Sorting/ Selection_sort.
[19] www.algorithmist.com/index.php/Stable _Sort.
[20] www.geeksforgeeks.org/forums/topic/inplace-sorting.

International Journal of Advanced Research in Engineering and Technology (IJARET), ISSN 0976 6480(Print),
ISSN 0976 6499(Online) Volume 5, Issue 9, September (2014), pp. 10-16 IAEME
16

ABOUT AUTHOR


Ms. Geeta student of M.Tech in Uttarakhand Technical University. She did her
B.tech. from Uttar Pradesh Technical University in 2007. She did M.Techs from
Karnataka State Open University in 2011. She did teaching in different institution.
Her area of interest is data structure, design and analysis of algorithms and image
processing.


Ms. Anubhooti Papola presently working as an assistant professor in Uttarakhand
Technical University. Before that she works in different institutions. She did her
B.tech. from H.N.B Garhwal University in 2009 and M.Tech from Graphic Era
University, Dehradun in 2012. Her area of interest is data structure and image
processing.

Você também pode gostar