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