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
插入排序(Insertion sort)是一种简单直观且稳定的排序算法。
function insertionSort(arr) { // 注意这里是从 arr[1] 开始的 for (var i = 1; i < arr.length; i++) { var preIndex = i - 1; var current = arr[i]; while (preIndex >= 0 && arr[preIndex] > current) { arr[preIndex + 1] = arr[preIndex]; preIndex--; } arr[preIndex + 1] = current; } return arr; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
插入排序
插入排序(Insertion sort)是一种简单直观且稳定的排序算法。
The text was updated successfully, but these errors were encountered: