dsalglib  1.0.0
dsalglib is a ready to use data structures and algorithms library written in C++ . Object Oriented Template implementations are written.
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
Definition: alginc.h:12
void insertionsort(array< type > arr, long long int size)
Definition: insertionsort.h:12