Use integer subproblem sizes and isolate the binary insertion demos (#2002)

Co-authored-by: Lukas <[email protected]>
This commit is contained in:
Lukas
2026-11-24 01:27:17 +08:00
committed by GitHub
parent 61ad6ed7f6
commit d5342f4ece
24 changed files with 240 additions and 192 deletions
@@ -100,7 +100,8 @@ function logRecur(n) {
/* 线性对数阶 */
function linearLogRecur(n) {
if (n <= 1) return 1;
let count = linearLogRecur(n / 2) + linearLogRecur(n / 2);
const half = Math.floor(n / 2);
let count = linearLogRecur(half) + linearLogRecur(half);
for (let i = 0; i < n; i++) {
count++;
}