You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution, you can watch the explanatoin here : https://youtu.be/xFqneyHR96g
void printArr(vector<int> arr){ for(int i = 0; i < arr.size(); i++){cout << arr[i] << " ";} cout << endl; } void insertionSort1(int n, vector<int> arr) { int last = arr[arr.size()-1]; for(int i = arr.size() - 1; i >= 0; i--){ if(last < arr[i-1]) { arr[i] = arr[i-1]; printArr(arr); } else{ arr[i] = last; printArr(arr); break; } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Insertion Sort - Part 1
You are viewing a single comment's thread. Return to all comments →
Here is my c++ solution, you can watch the explanatoin here : https://youtu.be/xFqneyHR96g