Click here to load reader
Upload
district-administration
View
59
Download
0
Embed Size (px)
Citation preview
Presentation on the topic Selection Sort
Presented By Saddam Hussain
Ravi Kr SinghRashan Pradhan
Raju Shah
Contents
Definition of Selection sort
Example
Algorithm with an Example
Advantage and disadvantages
conclusion
SELECTION SORT
In computer science,selection sort is a sortingalgorithm, specifically and inplace comparison sort. It has0(n2 time complexity.Selection sort is noted for itssimplicity and it hasperformance advantages.
HOW IT WORKS
The algorithm proceed by finding thesmallest (or largest depending onsorting order) element in the unsortedsublist , exchanging (swapping) it withthe left most unsorted element (puttingit in sorted order and have the sublistboundaries one element to the right.
FOR EXAMPLE
23 78 45 8 32 56 1
23 42 4 16 8 15
Current min=23
Algorithm
Step 1 − Set MIN to location 0
Step 2 − Search the minimum element in the list
Step 3 − Swap with value at location MIN
Step 4 − Increment MIN to point to next element
Step 5 − Repeat until list is sorted
for i=1 to n-1
min=I
for j=1+1 TO N
if array[j] < array[min]
min = j
if min != i
swap array[min] and array[i]
Advantages
The main advantage of the selection sort is that it performs well on a small list.
Because it is an in-place sorting algorithm, no additional temporary storage is required beyond what is needed to hold the original list.
Its performance is easily influenced by the initial ordering of the items before the sorting process.
Disadvantages
The primary disadvantage of the selection sort is its poor efficiency when dealing with a huge list of items.
The selection sort requires n-squared number of steps for sorting n elements.
References
www.tutorialpoints.com/selection_sort
www.wikipedia.com/selection_sort
www.google.com
Thank You