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
insertionsort.h
Go to the documentation of this file.
1
//
2
// Created by moghya_s on 12/26/2016.
3
//
4
5
#ifndef DSALGLIB_INSERTIONSORT_H
6
#define DSALGLIB_INSERTIONSORT_H
7
8
#include "
array.h
"
9
namespace
dsa
10
{
11
template
<
typename
type>
12
void
insertionsort
(
array<type>
arr,
long
long
int
size)
13
{
14
long
long
int
i,j,var;
15
for
(i=1;i<size;i++)
16
{
17
var = arr[i];
18
for
(j=i-1;j>=0&&var<arr[j];j--)
19
arr[j+1]=arr[j];
20
21
arr[j+1]=var;
22
23
}
24
}
25
}
26
#endif //DSALGLIB_INSERTIONSORT_H
dsa
Definition:
alginc.h:12
array.h
dsa::array
Definition:
array.h:10
dsa::insertionsort
void insertionsort(array< type > arr, long long int size)
Definition:
insertionsort.h:12
Generated by
1.8.11