Retranslate the complete English edition from Simplified Chinese (#2010)

* Retranslate the complete English edition from Simplified Chinese

* Polish three English explanations after reader-focused review
This commit is contained in:
Yudong Jin
2026-10-31 03:35:51 +08:00
committed by GitHub
parent ef46e2ed95
commit 14c314c08c
1502 changed files with 29459 additions and 23517 deletions

View File

@@ -4,7 +4,7 @@
* Author: Hello Algo Team
*/
/* Iterative summation */
/* Sum using iteration */
function sumIter(n) {
let res = 0;
for (let i = 1; i <= n; i++) {
@@ -13,7 +13,7 @@ function sumIter(n) {
return res;
}
/* Recursive summation */
/* Sum using recursion */
function sumRecur(n) {
if (n === 1) {
return 1;
@@ -21,7 +21,7 @@ function sumRecur(n) {
return n + sumRecur(n - 1);
}
/* Linear loop */
/* Linear-time loop */
function linearLoop(n) {
let res = 0;
for (let i = 0; i < n; i++) {
@@ -30,7 +30,7 @@ function linearLoop(n) {
return res;
}
/* Quadratic loop */
/* Quadratic-time loop */
function quadraticLoop(n) {
let res = 0;
for (let i = 0; i < n; i++) {
@@ -41,7 +41,7 @@ function quadraticLoop(n) {
return res;
}
/* Logarithmic loop */
/* Logarithmic-time loop */
function logarithmicLoop(n) {
while (n > 1) {
n = Math.floor(n / 2);
@@ -59,5 +59,5 @@ if (
logarithmicLoop(4) !== 1 ||
logarithmicLoop(5) !== 1
) {
throw new Error('complexity exercise check failed');
throw new Error('Complexity exercise check failed');
}