Commit c79408ec authored by Abhi's avatar Abhi

change implementation to insertion-sort

parent 0ea14c1d
......@@ -3,17 +3,17 @@
using namespace std;
vector<int> sort_custom(vector<int> v){
int i, j;
int n=v.size();
for (i = 0; i < n-1; i++){
for (j = 0; j < n-i-1; j++){
if (v[j] > v[j+1]){
int temp;
temp=v[j];
v[j]=v[j+1];
v[j+1]=temp;
}
}
int value,j=0;
for(int i=1;i<v.size();i++)
{
value = v[i];
j=i-1;
while(j>=0 && v[j]>value)
{
v[j+1] = v[j];
j=j-1;
}
v[j+1]=value;
}
return v;
}
\ No newline at end of file
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment