You are viewing a single comment's thread. Return to all comments →
function insertionSort1(n, arr) { // Write your code here let lastEl =arr[arr.length-1] for( let i = arr.length-1; i >= 0; i--){ if(lastEl < arr[i-1]){ // swap //let temp = arr[i] arr[i] = arr[i-1] console.log(arr.join(" ")) }else { arr[i] = lastEl console.log(arr.join(" ")) break } // (0)n } }
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 →
JS