Commit 76adf722 authored by DIDDI SAI KIRAN's avatar DIDDI SAI KIRAN

change implementation to insertion-sort

parent add2430f
#include<iostream>
#include "sorting.h"
#include"sorting.h"
using namespace std;
vector<int> sort_custom(vector<int> v1){
int i, j;
int n=v1.size();
for (i = 0; i < n-1; i++) {
for (j = 0; j < n-i-1; j++){
if (v1[j] > v1[j+1])
swap(v1[j], v1[j+1]);
vector<int> sort_custom( vector<int> a ){
int i, key, j;
int n=a.size();
for (i = 1; i < n; i++)
{
key = a[i];
j = i-1;
while (j >= 0 && a[j] > key)
{
a[j+1] = a[j];
j = j-1;
}
a[j+1] = key;
}
return v1;
return a;
}
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