SlideShare a Scribd company logo
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056
Volume: 03 Issue: 02 | Feb-2016 www.irjet.net p-ISSN: 2395-0072
© 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 528
SORTING ALGORITHMS
Neelam Yadav*, Sangeeta Kumari**
*HOD in CSE Dept, DAV college, Kanina
**Lecture in CSE Dept, DAV College, Kanina
---------------------------------------------------------------------------------------------------------------------------------------------------------------
Abstract: This paper presents different type of sorting that
are present in data structure for example quick, insertion,
heap and merge. Each algorithm tries to solve sorting
problem using different formats. These four algorithms have
their own pros and cons. This paper presents a detailed study
of how these algorithm works and compares them on the
basis of various parameters to reach a conclusion.
Keywords: Quick Sort, Selection Sort, Insertion Sort, Bubble
Sort, Shell Sort, Cocktail Sort, Comparison, Other
Performance Parameters.
1. INTRODUCTION
A sorting algorithm is an algorithm that arranges the
elements of a list in a certain order; the order can be
increasing or decreasing. Till now many sorting algorithm
has been discovered. Some of them were comparison based
sort like insertion sort, selection sort, bubble sort, quick
sort and merge sort while other were non comparison
based sort. When we try to sort any type of list, arrays etc.
we first compares element with one another then swaps or
copies those elements if necessary.
It continues executing over and over until the whole
array or list is sorted. Such algorithms are known as
Comparison based sorting.
Sorting algorithms often classified by [1]:
Internal Sorting: if data are sorted directly in main
memory
External Sorting: if data are sorted in auxiliary memory
like hard disk, floppy disk, etc.
System complexity: In terms of computational. In
this algorithm can be classified on basis of performance
like worst case, average case, and best case.
Computational complexity: In terms of number of swaps.
Each algorithm performs various numbers of swaps in
order to sort.
Memory usage
Stability: stable sorting algorithms maintains the relative
order if records with equal keys.
Sorting algorithms are sometimes characterized by big O
notation. This notation indicates performances of
algorithms and the amount of time that the algorithms
take. The different cases that are popular in sorting
algorithms are:-
- O(n) is fair, graph increases in the smooth
path.
- O(n^2): this is inefficient because a small increase in
input increases the graph tremendously.
- O(n log n): this is considered as efficient, because it
shows the slower pace increase in the graph as the size of
array or data is increased.
2. WORKING PROCEDURE OF
ALGORTIHMS
Bubble Sort: Bubble sort is a comparison based sort. It
is simplest among all comparison based sort. In this,
comparison is done among adjacent elements and if the top
data is greater than the data below it then they are
swapped [2]. It continues doing this for each pair of
adjacent elements till the end of the data set is reached. It
again starts comparing first two elements, repeating until
no swap occurs in pass. Unfortunately, it is a slowest
sorting method as compared to other sorting algorithms.
Algorithm [3]:-
Here N, K is a variable whose value is element position and
A is
Array of length
[1-N].
BUBBLE_SORT (A)
1. For N=1 to length[A]-1 (for
pass)
2. For k=1 to length[A]-N(for comparison)
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056
Volume: 03 Issue: 02 | Feb-2016 www.irjet.net p-ISSN: 2395-0072
© 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 529
3. If A[K]>A[K+1]
4. Swap [A(K) ,
A(K+1)]
[End if] [End of inner loop] [End of outer
loop]
5.Exit
Example:
election sort: It is a sorting algorithm that belongs to
in- place comparison sorting. It has O(n^2) complexity,
making it inefficient for large data sets
Algorithm:-
Here N, K,LOC is a variable whose value is a element
position, A
is Array of length [1-N] and min is minimum value of array
A.
SELECTION_SORT(A) [4]
1. for N=1 to length[A]-1 (finding minimum value for pass)
2. min=A [N]
3. for K=N+1 to length[A] (for comparison)
4. if (min>A [N])
5. min=A [K], Loc=K [End if] [End of inner loop]
6. Swap (A [Loc],A[N]) [End of OUTER loop]
7. Exit
Example:
Insertion Sort: Insertion sort is a naive algorithm. It
belongs to the family of comparison sorting. It is
efficient for sorting arrays with small size. It works by
taking elements from the list one by one and inserting
them at their correct position into a new sorted list.
Insertion sort is an example of an incremental algorithm. In
this sorting we scan the given list from 1 to n,
inserting each element into its proper position through
comparison. For sorting time n-1 passes or steps are
required.
Algorithm:-
Here K, J is a variable whose value is a element position and
A is
Array of length [1-N].
INSERTION_SORT (A)
1. For K=2 to length [A] (for
pass)
2. item= A [K], S=K-1 (for minimum number K-1
comparison)
3. WHILE S>0 and
item<A[S]
4.
A[S+1]=A[
S]
5. S=S-1 END WHILE
LOOP
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056
Volume: 03 Issue: 02 | Feb-2016 www.irjet.net p-ISSN: 2395-0072
© 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 530
6. A [S+1]=item .END FOR
LOOP
Example:
Quick Sort: Quick sort was developed by Sir Charles
Antony Richard Hoare [5] (Hoare 1962). It belongs to the
family of exchange sorting. Quick sort is an in-place,
divide-and-conquer algorithm. It is massively recursive
sort and is also termed as a partition-exchangesort.
Divide: The list is divided by choosing a partitioning
element (pivot element). One list contains all element less
than or equal to the partitioning element while the other
list contains all element greater than the partitioning
element.
Conquer: after these two lists are recursively partitioned
in the same way till the resulting lists become trivially small
to sort by comparison.
Combine: Lastly sorted smaller list is combined to
produce the sorted list which contains the entire input
element.
Example:
Shell sort: This sort was invented by Donald Shell in
1959. It is improvement over bubble sort and insertion
sort. One way to implement is to arrange the data
sequence in a two-dimensional array and then sort the
columns of the array using insertion sort.
This algorithm is inefficient for large data sets but
when comes to sorting smaller data set it perform well.
It is one of the fastest algorithms for sorting array with
smaller size.
Cocktail sort: It is also termed as bidirectional bubble
sort. Cocktail shaker sort, shaker sort (which can also refer
to a variant of selection sort), ripple sort, shuttle sort or
happy hour sort are other name for this [6]. It is a variation
of bubble sort. It is both a stable sorting algorithm and a
comparison based sort. The algorithm differs from bubble
sort in way where sorting is done in both directions in each
pass through the list. This sorting algorithm is only
marginally more difficult to implement than bubble sort,
and solves the problem with so-called turtles in bubble sort.
Name
Average
Case
Worst
Case
Stable
Bubble Sort O(n^2) O(n^2) yes
Insertion Sort O(n^2) O(n^2) yes
Quick Sort O(n log
n)
O(n^2) no
Cocktail Sort - O(n^2) yes
Selection Sort O(n^2) O(n^2) no
CONCLUSION
This paper discusses six comparison based sorting
algorithms and their example. Quick Sort is faster for than
Bubble Sort, Selection Sort and Insertion Sort when it
comes to sort large data sets.
International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056
Volume: 03 Issue: 02 | Feb-2016 www.irjet.net p-ISSN: 2395-0072
© 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 531
REFERENCES
[1] R. Lavore, Arrays, Big O Notation and simple Sorting.
Data Structures and Algorithms in Java.
[2] P. K. A. S. G. Eshan Kapur, "Proposal of a two way
sorting algorithm and performance with existing
algorithms,"Internationsl Journal of computer Science,
Engineering and application, vol. 2, no. 3, 2012.
[3] D. Knuth, in The art of programming sorting and
searching,1988.
[4] T. a. Cormen, Introduction to Algorithms, 2001.
[5] J.-p. T. T. M. Hill, An introduction to Data Structure
with application.
[6] J. Phongsai, "Research paper on Sorting Algorithm,"
2009.

More Related Content

What's hot (20)

PPTX
Quick sort
amar kakde
 
DOCX
Best,worst,average case .17581556 045
university of Gujrat, pakistan
 
PPT
13. Queue
Nilesh Dalvi
 
PDF
Quick sort algorithn
Kumar
 
PDF
Parallel sorting Algorithms
GARIMA SHAKYA
 
PPTX
Analysis of algorithms
iqbalphy1
 
PDF
Sorting
Gopi Saiteja
 
PDF
Svd filtered temporal usage clustering
Liang Xie, PhD
 
PPT
Standard Template Library
Nilesh Dalvi
 
PDF
Algorithem complexity in data sructure
Kumar
 
PDF
A statistical comparative study of
ijfcstjournal
 
PDF
Time series forecasting
Firas Kastantin
 
PPT
Algorithm
sultanarun
 
PPTX
Aa sort-v4
Malithi Edirisinghe
 
RTF
Design and Analysis of algorithms
Dr. Rupa Ch
 
PPTX
08 class and object
dhrubo kayal
 
Quick sort
amar kakde
 
Best,worst,average case .17581556 045
university of Gujrat, pakistan
 
13. Queue
Nilesh Dalvi
 
Quick sort algorithn
Kumar
 
Parallel sorting Algorithms
GARIMA SHAKYA
 
Analysis of algorithms
iqbalphy1
 
Sorting
Gopi Saiteja
 
Svd filtered temporal usage clustering
Liang Xie, PhD
 
Standard Template Library
Nilesh Dalvi
 
Algorithem complexity in data sructure
Kumar
 
A statistical comparative study of
ijfcstjournal
 
Time series forecasting
Firas Kastantin
 
Algorithm
sultanarun
 
Design and Analysis of algorithms
Dr. Rupa Ch
 
08 class and object
dhrubo kayal
 

Similar to Sorting Algorithms (20)

PDF
Study on Sorting Algorithm and Position Determining Sort
IRJET Journal
 
PDF
Analysis and Comparative of Sorting Algorithms
ijtsrd
 
PDF
Binary Sort
Love Arora
 
PDF
PROPOSAL OF A TWO WAY SORTING ALGORITHM AND PERFORMANCE COMPARISON WITH EXIST...
IJCSEA Journal
 
PDF
IRJET- Comparison of Stack and Queue Data Structures
IRJET Journal
 
PDF
Sorting_project_2.pdf
VrushaliSathe2
 
PDF
Ch24 efficient algorithms
rajatmay1992
 
PDF
The International Journal of Engineering and Science (The IJES)
theijes
 
PDF
A Variant of Modified Diminishing Increment Sorting: Circlesort and its Perfo...
CSCJournals
 
PDF
Empirical Analysis of Radix Sort using Curve Fitting Technique in Personal Co...
IRJET Journal
 
PDF
Methodology for Managing Dynamic Collections on Semantic Semi-Structured XMLs
IRJET Journal
 
PPTX
Complexity of algorithms
Jasur Ahmadov
 
PDF
IRJET- Optimum Design of Fan, Queen and Pratt Trusses
IRJET Journal
 
PDF
Class13_Quicksort_Algorithm.pdf
AkashSingh625550
 
PDF
IRJET- A Survey on Different Searching Algorithms
IRJET Journal
 
PPT
Data Structures 6
Dr.Umadevi V
 
PPTX
L16-L19-Searching&Sorting&string123.pptx
sidchat12
 
PDF
An efficient sorting algorithm increcomparision sort
IAEME Publication
 
PDF
An efficient sorting algorithm increcomparision sort 2
IAEME Publication
 
PDF
IRJET- Optimization of Cutting Parameters During Turning of AISI 1018 usi...
IRJET Journal
 
Study on Sorting Algorithm and Position Determining Sort
IRJET Journal
 
Analysis and Comparative of Sorting Algorithms
ijtsrd
 
Binary Sort
Love Arora
 
PROPOSAL OF A TWO WAY SORTING ALGORITHM AND PERFORMANCE COMPARISON WITH EXIST...
IJCSEA Journal
 
IRJET- Comparison of Stack and Queue Data Structures
IRJET Journal
 
Sorting_project_2.pdf
VrushaliSathe2
 
Ch24 efficient algorithms
rajatmay1992
 
The International Journal of Engineering and Science (The IJES)
theijes
 
A Variant of Modified Diminishing Increment Sorting: Circlesort and its Perfo...
CSCJournals
 
Empirical Analysis of Radix Sort using Curve Fitting Technique in Personal Co...
IRJET Journal
 
Methodology for Managing Dynamic Collections on Semantic Semi-Structured XMLs
IRJET Journal
 
Complexity of algorithms
Jasur Ahmadov
 
IRJET- Optimum Design of Fan, Queen and Pratt Trusses
IRJET Journal
 
Class13_Quicksort_Algorithm.pdf
AkashSingh625550
 
IRJET- A Survey on Different Searching Algorithms
IRJET Journal
 
Data Structures 6
Dr.Umadevi V
 
L16-L19-Searching&Sorting&string123.pptx
sidchat12
 
An efficient sorting algorithm increcomparision sort
IAEME Publication
 
An efficient sorting algorithm increcomparision sort 2
IAEME Publication
 
IRJET- Optimization of Cutting Parameters During Turning of AISI 1018 usi...
IRJET Journal
 
Ad

More from IRJET Journal (20)

PDF
Enhanced heart disease prediction using SKNDGR ensemble Machine Learning Model
IRJET Journal
 
PDF
Utilizing Biomedical Waste for Sustainable Brick Manufacturing: A Novel Appro...
IRJET Journal
 
PDF
Kiona – A Smart Society Automation Project
IRJET Journal
 
PDF
DESIGN AND DEVELOPMENT OF BATTERY THERMAL MANAGEMENT SYSTEM USING PHASE CHANG...
IRJET Journal
 
PDF
Invest in Innovation: Empowering Ideas through Blockchain Based Crowdfunding
IRJET Journal
 
PDF
SPACE WATCH YOUR REAL-TIME SPACE INFORMATION HUB
IRJET Journal
 
PDF
A Review on Influence of Fluid Viscous Damper on The Behaviour of Multi-store...
IRJET Journal
 
PDF
Wireless Arduino Control via Mobile: Eliminating the Need for a Dedicated Wir...
IRJET Journal
 
PDF
Explainable AI(XAI) using LIME and Disease Detection in Mango Leaf by Transfe...
IRJET Journal
 
PDF
BRAIN TUMOUR DETECTION AND CLASSIFICATION
IRJET Journal
 
PDF
The Project Manager as an ambassador of the contract. The case of NEC4 ECC co...
IRJET Journal
 
PDF
"Enhanced Heat Transfer Performance in Shell and Tube Heat Exchangers: A CFD ...
IRJET Journal
 
PDF
Advancements in CFD Analysis of Shell and Tube Heat Exchangers with Nanofluid...
IRJET Journal
 
PDF
Breast Cancer Detection using Computer Vision
IRJET Journal
 
PDF
Auto-Charging E-Vehicle with its battery Management.
IRJET Journal
 
PDF
Analysis of high energy charge particle in the Heliosphere
IRJET Journal
 
PDF
A Novel System for Recommending Agricultural Crops Using Machine Learning App...
IRJET Journal
 
PDF
Auto-Charging E-Vehicle with its battery Management.
IRJET Journal
 
PDF
Analysis of high energy charge particle in the Heliosphere
IRJET Journal
 
PDF
Wireless Arduino Control via Mobile: Eliminating the Need for a Dedicated Wir...
IRJET Journal
 
Enhanced heart disease prediction using SKNDGR ensemble Machine Learning Model
IRJET Journal
 
Utilizing Biomedical Waste for Sustainable Brick Manufacturing: A Novel Appro...
IRJET Journal
 
Kiona – A Smart Society Automation Project
IRJET Journal
 
DESIGN AND DEVELOPMENT OF BATTERY THERMAL MANAGEMENT SYSTEM USING PHASE CHANG...
IRJET Journal
 
Invest in Innovation: Empowering Ideas through Blockchain Based Crowdfunding
IRJET Journal
 
SPACE WATCH YOUR REAL-TIME SPACE INFORMATION HUB
IRJET Journal
 
A Review on Influence of Fluid Viscous Damper on The Behaviour of Multi-store...
IRJET Journal
 
Wireless Arduino Control via Mobile: Eliminating the Need for a Dedicated Wir...
IRJET Journal
 
Explainable AI(XAI) using LIME and Disease Detection in Mango Leaf by Transfe...
IRJET Journal
 
BRAIN TUMOUR DETECTION AND CLASSIFICATION
IRJET Journal
 
The Project Manager as an ambassador of the contract. The case of NEC4 ECC co...
IRJET Journal
 
"Enhanced Heat Transfer Performance in Shell and Tube Heat Exchangers: A CFD ...
IRJET Journal
 
Advancements in CFD Analysis of Shell and Tube Heat Exchangers with Nanofluid...
IRJET Journal
 
Breast Cancer Detection using Computer Vision
IRJET Journal
 
Auto-Charging E-Vehicle with its battery Management.
IRJET Journal
 
Analysis of high energy charge particle in the Heliosphere
IRJET Journal
 
A Novel System for Recommending Agricultural Crops Using Machine Learning App...
IRJET Journal
 
Auto-Charging E-Vehicle with its battery Management.
IRJET Journal
 
Analysis of high energy charge particle in the Heliosphere
IRJET Journal
 
Wireless Arduino Control via Mobile: Eliminating the Need for a Dedicated Wir...
IRJET Journal
 
Ad

Recently uploaded (20)

PDF
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
PDF
Electrical Engineer operation Supervisor
ssaruntatapower143
 
PPTX
Day2 B2 Best.pptx
helenjenefa1
 
PPTX
Hashing Introduction , hash functions and techniques
sailajam21
 
PPTX
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
PPTX
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PPTX
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
PDF
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
PPTX
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
PDF
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PPT
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PPTX
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPTX
Introduction to Design of Machine Elements
PradeepKumarS27
 
PPTX
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
PDF
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 
Set Relation Function Practice session 24.05.2025.pdf
DrStephenStrange4
 
Electrical Engineer operation Supervisor
ssaruntatapower143
 
Day2 B2 Best.pptx
helenjenefa1
 
Hashing Introduction , hash functions and techniques
sailajam21
 
Damage of stability of a ship and how its change .pptx
ehamadulhaque
 
Depth First Search Algorithm in 🧠 DFS in Artificial Intelligence (AI)
rafeeqshaik212002
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Solar Thermal Energy System Seminar.pptx
Gpc Purapuza
 
Biomechanics of Gait: Engineering Solutions for Rehabilitation (www.kiu.ac.ug)
publication11
 
Worm gear strength and wear calculation as per standard VB Bhandari Databook.
shahveer210504
 
Viol_Alessandro_Presentazione_prelaurea.pdf
dsecqyvhbowrzxshhf
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
Carmon_Remote Sensing GIS by Mahesh kumar
DhananjayM6
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
265587293-NFPA 101 Life safety code-PPT-1.pptx
chandermwason
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
Introduction to Design of Machine Elements
PradeepKumarS27
 
Shinkawa Proposal to meet Vibration API670.pptx
AchmadBashori2
 
Introduction to Productivity and Quality
মোঃ ফুরকান উদ্দিন জুয়েল
 

Sorting Algorithms

  • 1. International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056 Volume: 03 Issue: 02 | Feb-2016 www.irjet.net p-ISSN: 2395-0072 © 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 528 SORTING ALGORITHMS Neelam Yadav*, Sangeeta Kumari** *HOD in CSE Dept, DAV college, Kanina **Lecture in CSE Dept, DAV College, Kanina --------------------------------------------------------------------------------------------------------------------------------------------------------------- Abstract: This paper presents different type of sorting that are present in data structure for example quick, insertion, heap and merge. Each algorithm tries to solve sorting problem using different formats. These four algorithms have their own pros and cons. This paper presents a detailed study of how these algorithm works and compares them on the basis of various parameters to reach a conclusion. Keywords: Quick Sort, Selection Sort, Insertion Sort, Bubble Sort, Shell Sort, Cocktail Sort, Comparison, Other Performance Parameters. 1. INTRODUCTION A sorting algorithm is an algorithm that arranges the elements of a list in a certain order; the order can be increasing or decreasing. Till now many sorting algorithm has been discovered. Some of them were comparison based sort like insertion sort, selection sort, bubble sort, quick sort and merge sort while other were non comparison based sort. When we try to sort any type of list, arrays etc. we first compares element with one another then swaps or copies those elements if necessary. It continues executing over and over until the whole array or list is sorted. Such algorithms are known as Comparison based sorting. Sorting algorithms often classified by [1]: Internal Sorting: if data are sorted directly in main memory External Sorting: if data are sorted in auxiliary memory like hard disk, floppy disk, etc. System complexity: In terms of computational. In this algorithm can be classified on basis of performance like worst case, average case, and best case. Computational complexity: In terms of number of swaps. Each algorithm performs various numbers of swaps in order to sort. Memory usage Stability: stable sorting algorithms maintains the relative order if records with equal keys. Sorting algorithms are sometimes characterized by big O notation. This notation indicates performances of algorithms and the amount of time that the algorithms take. The different cases that are popular in sorting algorithms are:- - O(n) is fair, graph increases in the smooth path. - O(n^2): this is inefficient because a small increase in input increases the graph tremendously. - O(n log n): this is considered as efficient, because it shows the slower pace increase in the graph as the size of array or data is increased. 2. WORKING PROCEDURE OF ALGORTIHMS Bubble Sort: Bubble sort is a comparison based sort. It is simplest among all comparison based sort. In this, comparison is done among adjacent elements and if the top data is greater than the data below it then they are swapped [2]. It continues doing this for each pair of adjacent elements till the end of the data set is reached. It again starts comparing first two elements, repeating until no swap occurs in pass. Unfortunately, it is a slowest sorting method as compared to other sorting algorithms. Algorithm [3]:- Here N, K is a variable whose value is element position and A is Array of length [1-N]. BUBBLE_SORT (A) 1. For N=1 to length[A]-1 (for pass) 2. For k=1 to length[A]-N(for comparison)
  • 2. International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056 Volume: 03 Issue: 02 | Feb-2016 www.irjet.net p-ISSN: 2395-0072 © 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 529 3. If A[K]>A[K+1] 4. Swap [A(K) , A(K+1)] [End if] [End of inner loop] [End of outer loop] 5.Exit Example: election sort: It is a sorting algorithm that belongs to in- place comparison sorting. It has O(n^2) complexity, making it inefficient for large data sets Algorithm:- Here N, K,LOC is a variable whose value is a element position, A is Array of length [1-N] and min is minimum value of array A. SELECTION_SORT(A) [4] 1. for N=1 to length[A]-1 (finding minimum value for pass) 2. min=A [N] 3. for K=N+1 to length[A] (for comparison) 4. if (min>A [N]) 5. min=A [K], Loc=K [End if] [End of inner loop] 6. Swap (A [Loc],A[N]) [End of OUTER loop] 7. Exit Example: Insertion Sort: Insertion sort is a naive algorithm. It belongs to the family of comparison sorting. It is efficient for sorting arrays with small size. It works by taking elements from the list one by one and inserting them at their correct position into a new sorted list. Insertion sort is an example of an incremental algorithm. In this sorting we scan the given list from 1 to n, inserting each element into its proper position through comparison. For sorting time n-1 passes or steps are required. Algorithm:- Here K, J is a variable whose value is a element position and A is Array of length [1-N]. INSERTION_SORT (A) 1. For K=2 to length [A] (for pass) 2. item= A [K], S=K-1 (for minimum number K-1 comparison) 3. WHILE S>0 and item<A[S] 4. A[S+1]=A[ S] 5. S=S-1 END WHILE LOOP
  • 3. International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056 Volume: 03 Issue: 02 | Feb-2016 www.irjet.net p-ISSN: 2395-0072 © 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 530 6. A [S+1]=item .END FOR LOOP Example: Quick Sort: Quick sort was developed by Sir Charles Antony Richard Hoare [5] (Hoare 1962). It belongs to the family of exchange sorting. Quick sort is an in-place, divide-and-conquer algorithm. It is massively recursive sort and is also termed as a partition-exchangesort. Divide: The list is divided by choosing a partitioning element (pivot element). One list contains all element less than or equal to the partitioning element while the other list contains all element greater than the partitioning element. Conquer: after these two lists are recursively partitioned in the same way till the resulting lists become trivially small to sort by comparison. Combine: Lastly sorted smaller list is combined to produce the sorted list which contains the entire input element. Example: Shell sort: This sort was invented by Donald Shell in 1959. It is improvement over bubble sort and insertion sort. One way to implement is to arrange the data sequence in a two-dimensional array and then sort the columns of the array using insertion sort. This algorithm is inefficient for large data sets but when comes to sorting smaller data set it perform well. It is one of the fastest algorithms for sorting array with smaller size. Cocktail sort: It is also termed as bidirectional bubble sort. Cocktail shaker sort, shaker sort (which can also refer to a variant of selection sort), ripple sort, shuttle sort or happy hour sort are other name for this [6]. It is a variation of bubble sort. It is both a stable sorting algorithm and a comparison based sort. The algorithm differs from bubble sort in way where sorting is done in both directions in each pass through the list. This sorting algorithm is only marginally more difficult to implement than bubble sort, and solves the problem with so-called turtles in bubble sort. Name Average Case Worst Case Stable Bubble Sort O(n^2) O(n^2) yes Insertion Sort O(n^2) O(n^2) yes Quick Sort O(n log n) O(n^2) no Cocktail Sort - O(n^2) yes Selection Sort O(n^2) O(n^2) no CONCLUSION This paper discusses six comparison based sorting algorithms and their example. Quick Sort is faster for than Bubble Sort, Selection Sort and Insertion Sort when it comes to sort large data sets.
  • 4. International Research Journal of Engineering and Technology (IRJET) e-ISSN: 2395 -0056 Volume: 03 Issue: 02 | Feb-2016 www.irjet.net p-ISSN: 2395-0072 © 2016, IRJET | Impact Factor value: 4.45 | ISO 9001:2008 Certified Journal | Page 531 REFERENCES [1] R. Lavore, Arrays, Big O Notation and simple Sorting. Data Structures and Algorithms in Java. [2] P. K. A. S. G. Eshan Kapur, "Proposal of a two way sorting algorithm and performance with existing algorithms,"Internationsl Journal of computer Science, Engineering and application, vol. 2, no. 3, 2012. [3] D. Knuth, in The art of programming sorting and searching,1988. [4] T. a. Cormen, Introduction to Algorithms, 2001. [5] J.-p. T. T. M. Hill, An introduction to Data Structure with application. [6] J. Phongsai, "Research paper on Sorting Algorithm," 2009.