av1shek / All-Coding-Platform-Solutions

Repository accepting PR for Hactoberfest 2022
21 stars 128 forks source link

Create insertionSort.cpp #193

Closed SONIYAPATIDAR closed 1 year ago

SONIYAPATIDAR commented 1 year ago

include

include

using namespace std; void insertionSort(vector&arr){ for(int i=1;i<arr.size(); i++){ int key=arr[i]; int j=i-1; while(j>=0&&arr[j]>key){ arr[j+1]=arr[j]; j--; arr[j+1]=key; }

} for(int ele:arr){ cout<<ele<<" ";

 }
 cout<<"\n";

}

int main(){ vectorarr={1,4,6,8,5,9}; insertionSort(arr);

}

av1shek commented 1 year ago

Please add the filename inside a folder from the coding platform it belongs. Also add problem code in filename. For details please check guidelines in readme.