dsalglib
1.0.0
dsalglib is a ready to use data structures and algorithms library written in C++ . Object Oriented Template implementations are written.
Main Page
Namespaces
Classes
Files
File List
File Members
source
include
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
dsa::swapit
void swapit(T &x, T &y)
Definition:
alginc.h:17
dsa
Definition:
alginc.h:12
dsa::selectionsort
void selectionsort(array< type > arr, long long int size)
Definition:
selectionsort.h:13
array.h
dsa::array
Definition:
array.h:10
Generated by
1.8.11