A New Approach To Sorting Min Max Sorting Algorithm IJERTV2IS50210 PDF
A New Approach To Sorting Min Max Sorting Algorithm IJERTV2IS50210 PDF
ISSN: 2278-0181
Vol. 2 Issue 5, May - 2013
Many algorithms are available for sorting the The Min-Max Sorting Algorithm works on the
unordered elements. Most important of them are minimum and maximum element of the array. It finds
Bubble sort, Heap sort, Insertion sort and Quick sort. the minimum and maximum element from the array
This paper presents the new algorithm for sorting the and set on the first and last position of the array.
elements which is based on minimum and maximum Then the array index increment from the first position
elements of the array which results in placing the and decrement from the last position to get the new
elements at appropriate position. This will reduce the array. From this new array, it again finds the
number of passes in which the sorting takes place. minimum and maximum element and set on their
We will examine this sorting technique and compare respective positions. In this way, this sorting
with the other available sorting algorithms in terms algorithm sorts the elements of the array.
of complexity, memory and other factors. Here we provide the Pseudo-Code for this sorting
algorithm.
www.ijert.org 445
International Journal of Engineering Research & Technology (IJERT)
ISSN: 2278-0181
Vol. 2 Issue 5, May - 2013
#include<stdio.h>
#include<conio.h> OUTPUT
void minimum(int a[],int p,int q) How many elements you want to enter…?
{ 6
int min=a[p]; 23 43 12 54 27 5
for(int l=p;l<=q;l++) Your Array is: 23 43 12 54 27 5
{ Sorted Array is: 5 12 23 27 43 54
if(a[l]<min)
RT
{
int temp=min; 3. COMPARATIVE STUDY WITH
min=a[l]; OTHER ALGORITHMS
IJE
a[l]=temp;
} In this section, we provide the comparison of our
a[p]=min; Min-Max sorting algorithm with others existing
} sorting algorithms in different cases with example.
}
void maximum(int a[],int p,int q) A. Comparison in terms of Time Complexity
{ with other Algorithms:
int max=a[q];
for(int i=p;i<=q;i++) Table 1: Complexity Comparison
{ NAME BEST CASE AVERAGE WORST CASE
CASE
int temp;
if(a[i]>max) MIN-MAX n2 n2 n2
{ SORT
temp=a[i];
QUICKSORT nlog n nlog n n2
a[i]=a[q];
a[q]=temp;
} HEAP SORT nlog n nlog n nlog n
max=a[q];
} MERGE nlog n nlog n nlog n
} SORT
void main()
BUBBLE n n2 n2
{ SORT
Clrscr();
int n,a[20]; SELECTION n2 n2 n2
SORT
printf("\nHow many element you want to
enter...?\n"); INSERTION n n2 n2
scanf("%d",&n); SORT
www.ijert.org 446
International Journal of Engineering Research & Technology (IJERT)
ISSN: 2278-0181
Vol. 2 Issue 5, May - 2013
B. Comparison in Number of Passes to Sort the It will take four passes to sort the elements. In
Elements: General, it takes (n-1) passes to sort the elements
where n is the number of elements. It takes just
This comparison is shown by taking an example. In double passes to sort the elements compare to Min-
this, we have an array of 5 integers andwe are Max sorting.
differentiating sorting algorithms in terms of number
of passes and proved that our algorithm takes Selection Sort:
minimum number of passes to sort an array. Here we
are comparing only with two sorting i.e., Selection 2, 3, 5, 1, 4 (Given Array)
sort and bubble sort.
Let us take an example: 1, 3, 5, 2, 4 Pass 1
Array: 5 4 3 2 1
1, 2, 5, 3, 4 Pass 2
Min-Max Sorting:
1, 2, 3,5, 4 Pass 3
2, 3, 5, 1, 4 (Given Array)
1, 2, 3, 4, 5 Pass 4
1, 3, 5, 2, 4 (After Minimum Function)
1, 3, 4, 2, 5 (After MaximumFunction) Pass 1 It will also take (n-1) passes just taking double time
compare to Min-Max sorting algorithm.
1, 3, 4, 2, 5 (After Minimum Function)
1, 2, 4, 3, 5 (After Maximum Function) Pass 2 C. Comparison in terms of other factors:
1, 2, 3, 4, 5 Resultant Sorted Array All the sorting algorithms have two properties on
which they follow. Some sorting algorithms follow
It will take only two passes to sort the elements. In these properties but some are not. Our sorting
RT
General, it takes n / 2 passes to sort the elements
algorithm follows these properties which are as
follows:
where n is the number of elements.
IJE
www.ijert.org 447
International Journal of Engineering Research & Technology (IJERT)
ISSN: 2278-0181
Vol. 2 Issue 5, May - 2013
Table 2: Comparison in terms of Stable [9] Sedgewick, Robert. Fundamentals, Data Structures,
and Inplace Sorting Sorting, Searching, and Graph Algorithms. Bundle of
Algorithms in Java, Third Edition. Addison-
NAME STABLE INPLACE
WesleyProfessional, 9780201775785.
[10] www.algorithmist.com/index.php/Stable_Sort
MIN-MAX SORT YES YES [11] www.geeksforgeeks.org/forums/topic/inplace-sorting
4. CONCLUSION
REFERENCES
www.ijert.org 448