mirror of
https://github.com/krahets/hello-algo.git
synced 2026-11-12 08:48:50 +08:00
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:
@@ -6,7 +6,7 @@ Author: Hello Algo Team
|
||||
|
||||
|
||||
def sum_iter(n: int) -> int:
|
||||
"""Iterative summation"""
|
||||
"""Sum using iteration"""
|
||||
res = 0
|
||||
for i in range(1, n + 1):
|
||||
res += i
|
||||
@@ -14,14 +14,14 @@ def sum_iter(n: int) -> int:
|
||||
|
||||
|
||||
def sum_recur(n: int) -> int:
|
||||
"""Recursive summation"""
|
||||
"""Sum using recursion"""
|
||||
if n == 1:
|
||||
return 1
|
||||
return n + sum_recur(n - 1)
|
||||
|
||||
|
||||
def linear_loop(n: int) -> int:
|
||||
"""Linear loop"""
|
||||
"""Linear-time loop"""
|
||||
res = 0
|
||||
for i in range(n):
|
||||
res += i
|
||||
@@ -29,7 +29,7 @@ def linear_loop(n: int) -> int:
|
||||
|
||||
|
||||
def quadratic_loop(n: int) -> int:
|
||||
"""Quadratic loop"""
|
||||
"""Quadratic-time loop"""
|
||||
res = 0
|
||||
for i in range(n):
|
||||
for j in range(i, n):
|
||||
@@ -38,7 +38,7 @@ def quadratic_loop(n: int) -> int:
|
||||
|
||||
|
||||
def logarithmic_loop(n: int) -> int:
|
||||
"""Logarithmic loop"""
|
||||
"""Logarithmic-time loop"""
|
||||
while n > 1:
|
||||
n //= 2
|
||||
return n
|
||||
|
||||
Reference in New Issue
Block a user