mirror of
https://github.com/142vip/408CSFamily.git
synced 2026-04-13 18:00:58 +08:00
feat: 修改代码
This commit is contained in:
@@ -13,7 +13,7 @@ function binaryInsertSort(arr, len) {
|
||||
|
||||
while (lowIndex <= highIndex) {
|
||||
// 注意:取整,javascript这里取整,会出现空指针
|
||||
const mid = parseInt((lowIndex + highIndex) / 2)
|
||||
const mid = Math.ceil((lowIndex + highIndex) / 2)
|
||||
|
||||
if (arr[mid] <= temp) {
|
||||
// 右侧
|
||||
@@ -24,7 +24,6 @@ function binaryInsertSort(arr, len) {
|
||||
}
|
||||
}
|
||||
// 元素后移
|
||||
|
||||
for (let j = i - 1; j > highIndex; --j) {
|
||||
arr[j + 1] = arr[j]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user