(Javascript) selectionSort
selectionSort(선택정렬) function swap(arr, idx1, idx2) { const temp = arr[idx1]; arr[idx1] = arr[idx2]; arr[idx2] = temp; } function selectSort(arr) { const tempArr = [...arr]; for (let i = 0; i tempArr[j]) minIdx = j; } swap(tempArr, minIdx, i); } return tempArr; } 선택정렬은 배열의 최솟값을 찾아서 그걸..
2023.01.16