mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-08 07:15:59 +08:00
fix: Use int instead of float for the example code of log time complexity (#1164)
* Use int instead of float for the example code of log time complexity * Bug fixes * Bug fixes
This commit is contained in:
@ -77,7 +77,7 @@ def exp_recur(n: int) -> int:
|
||||
return exp_recur(n - 1) + exp_recur(n - 1) + 1
|
||||
|
||||
|
||||
def logarithmic(n: float) -> int:
|
||||
def logarithmic(n: int) -> int:
|
||||
"""对数阶(循环实现)"""
|
||||
count = 0
|
||||
while n > 1:
|
||||
@ -86,14 +86,14 @@ def logarithmic(n: float) -> int:
|
||||
return count
|
||||
|
||||
|
||||
def log_recur(n: float) -> int:
|
||||
def log_recur(n: int) -> int:
|
||||
"""对数阶(递归实现)"""
|
||||
if n <= 1:
|
||||
return 0
|
||||
return log_recur(n / 2) + 1
|
||||
|
||||
|
||||
def linear_log_recur(n: float) -> int:
|
||||
def linear_log_recur(n: int) -> int:
|
||||
"""线性对数阶"""
|
||||
if n <= 1:
|
||||
return 1
|
||||
|
Reference in New Issue
Block a user