You are viewing a single comment's thread. Return to all comments →
JavaScript Solution
function insertionSort2(n, arr) { // Write your code here for(let i=0; i<n-1; i++){ // From here, This block of code performs Insertion Sort-1 if(arr[i+1] < arr[i]){ var val = arr[i+1], j = i; while(arr[j] > val){ arr[j+1] = arr[j]; j--; } arr[j+1] = val; } // End of insertion sort - 1 console.log(...arr) }
}
Insertion Sort - Part 2
You are viewing a single comment's thread. Return to all comments →
JavaScript Solution
}