1
0
mirror of https://github.com/142vip/408CSFamily.git synced 2026-04-13 18:00:58 +08:00

perf: 升级依赖版本,支持锁定node18.18

This commit is contained in:
mmdapl
2023-09-28 11:08:37 +08:00
committed by GitHub
parent f0d5e05936
commit a1dfbaf1d3
22 changed files with 2461 additions and 1924 deletions

View File

@@ -7,9 +7,11 @@ function binaryInsertSort(arr, len) {
? len
: arr.length
// 遍历
for (let i = 1; i < len; i++) {
const temp = arr[i]
let lowIndex = 0; let highIndex = i - 1
let lowIndex = 0
let highIndex = i - 1
while (lowIndex <= highIndex) {
// 注意:取整,javascript这里取整会出现空指针
@@ -29,15 +31,14 @@ function binaryInsertSort(arr, len) {
}
arr[highIndex + 1] = temp
}
// 返回经过折半插入排序处理的有序数组
return arr
}
// 测试用例
const dealArr = [5, 2, 7, 3, 18, 8, 12, 1]
console.log('插入排序前:', dealArr)
const sortResult = binaryInsertSort(dealArr, 7)
console.log('插入排序后:', sortResult)