You are viewing a single comment's thread. Return to all comments →
Simple Javascript solution:
function insertionSort2(n, arr) { for (let i = 1; i < n; i++) { let current = i; while (arr[current] < arr[current - 1]) { let temp = arr[current]; arr[current] = arr[current - 1]; arr[current - 1] = temp; current--; } console.log(arr.join(" ")); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Insertion Sort - Part 2
You are viewing a single comment's thread. Return to all comments →
Simple Javascript solution: