Commit 11019fe9 authored by Neeraj Kerkar's avatar Neeraj Kerkar

changed implementation to insertion-sort

parent bbf91dfe
......@@ -2,22 +2,21 @@
using namespace std;
vector<int> sort_custom(vector<int> a)
{
bool swapp = true;
while(swapp)
{
swapp = false;
for (int i = 0; i < a.size()-1; i++)
{
if (a[i]>a[i+1] )
{
a[i] += a[i+1];
a[i+1] = a[i] - a[i+1];
a[i] -=a[i+1];
swapp = true;
}
vector<int> sort_custom(vector<int> array){
unsigned int i, j;
vector<int> sortedArray;
int max;
for(i = 0; i<array.size();i++){
max = array[i];
for(j = i; j<array.size();j++){
max = array[j] > max ? array[j]:max;
}
sortedArray[i] = max;
}
return a;
return sortedArray;
}
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