dsalglib  1.0.0
dsalglib is a ready to use data structures and algorithms library written in C++ . Object Oriented Template implementations are written.
selectionsort.h
Go to the documentation of this file.
1 //
2 // Created by moghya_s on 12/26/2016.
3 //
4 
5 #ifndef DSALGLIB_SELECTIONSORT_H
6 #define DSALGLIB_SELECTIONSORT_H
7 
8 #include "array.h"
9 namespace dsa
10 {
11 
12  template<typename type>
13  void selectionsort(array<type> arr,long long int size)
14  {
15  long long int i,j,k,min;
16  for(i=0;i<size;i++)
17  {
18  min = i;
19  for(j=i+1;j<size;j++)
20  {
21  if(arr[j]<arr[min])
22  min = j;
23  }
24 
25  swapit(arr[i],arr[min]);
26  }
27  }
28 
29 }
30 #endif //DSALGLIB_SELECTIONSORT_H
void swapit(T &x, T &y)
Definition: alginc.h:17
Definition: alginc.h:12
void selectionsort(array< type > arr, long long int size)
Definition: selectionsort.h:13