Commit 44a1e97d authored by RAMOLLA NIKHIL REDDY's avatar RAMOLLA NIKHIL REDDY

change implementation to insertion-sort

parent 6a5d2ec6
#include "sorting.h" #include "sorting.h"
using namespace std; using namespace std;
vector<int> sort_custom(vector<int> arr){
int N=arr.size(); vector<int> sort_custom(vector<int> data) {
for(int i=0;i<N;i++) int N = data.size(), j;
for(int j=0;j<N-i-1;j++) for(int i=0; i<N; i++) {
if(arr[j]>arr[j+1]) for(j=0; j<i; j++) if(data[j] > data[i]) break;
swap(arr[j],arr[j+1]); for(; j<i; j++) swap(data[j], data[i]);
return arr; }
return data;
} }
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