You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
for(int i = 1; i < length; i++){ //outer loop gonna go thru every element of the array starting by the index 1, because the first index will be sorted anyway;
int key = a[i]; //key will receive the value of the current element; 5 in our example at the very start;
int j = i - 1;
while(j >= 0 && a[j] > key) { //it means that the value before the current index must be bigger than the value of the current index in order to start the loop;
a[j + 1] = a[j]; //this line does the swap of the elements of the array;