SelectionSort

Run Settings
LanguageJavaScript
Language Version
Run Command
const selectionSort = (arr)=>{ let time = Date.now(); for(let i=0;i<arr.length;i++) { let min = i; for(j=i+1; j<arr.length;j++) { if(arr[min]>arr[j]) { min = j; } } let temp = arr[i]; arr[i] = arr[min]; arr[min] = temp; } console.log(`Time taken = ${(Date.now()-time)/1000} seconds`); return arr; } let array = Array.from({length : 100000},(x,i)=>Math.floor(Math.random()*i)); console.log(selectionSort(array))
Editor Settings
Theme
Key bindings
Full width
Lines