We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
选择排序可视化视频
选择排序和插入排序有些类似,也分已排序序列和未排序序列。
但是选择排序是将最小的元素存放在数组起始位置,再从剩下的未排序的序列中寻找最小的元素,然后将其放到已排序的序列后面。以此类推,直到排序完成。
将最小的元素存放在数组起始位置,再从剩下的未排序的序列中寻找最小的元素,然后将其放到已排序的序列后面
const selectSort = function(arr) { const len = arr.length let temp, minIndex for (let i = 0; i < len - 1; i++) { minIndex = i for (let j = i + 1; j < len; j++) { if (arr[j] <= arr[minIndex]) { minIndex = j } } temp = arr[i] arr[i] = arr[minIndex] arr[minIndex] = temp } return arr }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
选择排序可视化视频
选择排序和插入排序有些类似,也分已排序序列和未排序序列。
但是选择排序是
将最小的元素存放在数组起始位置,再从剩下的未排序的序列中寻找最小的元素,然后将其放到已排序的序列后面
。以此类推,直到排序完成。The text was updated successfully, but these errors were encountered: