FANDOM


16px-Pencil

Selection Sort is a list sorting algorithm. It is very easy to implement but is rather inefficient.

Algorithm Edit

For each position in the List the algorithm searches for the smallest Item in the list starting at that point. When that item is found it is swapped into the current position.

Examples Edit

PseudocodeEdit

selection sort(list[1 to n])
   for i = 1 to n - 1
      minimum = i
      for j = i + 1 to n
         if list at j jkloipi9

== External links ==
{{wp|Selection sort}}

{{Sorting algorithms}}
[[Category:Algorithms]]

SELECTION SORT (A(n))

1   for i = 1 to n-1

2     min = i

3     for j= i+1 to n

4         if A[j]<A[i]

5            min = j

6            temp = A[i]

7             A[i] = A[min]

8             A[min] = temp

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.