Add return value for recur function of Python in space complexity (#1169)
* Add return value for recur function of Python in space complexity * Update space_complexity.md * Update space_complexity.md --------- Co-authored-by: Yudong Jin <krahets@163.com>
This commit is contained in:
parent
739ee24751
commit
55db99ab18
@ -476,9 +476,10 @@ Consider the following code, the term "worst-case" in worst-case space complexit
|
||||
for _ in range(n):
|
||||
function()
|
||||
|
||||
def recur(n: int) -> int:
|
||||
def recur(n: int):
|
||||
"""Recursion O(n)"""""
|
||||
if n == 1: return
|
||||
if n == 1:
|
||||
return
|
||||
return recur(n - 1)
|
||||
```
|
||||
|
||||
|
@ -475,9 +475,10 @@
|
||||
for _ in range(n):
|
||||
function()
|
||||
|
||||
def recur(n: int) -> int:
|
||||
def recur(n: int):
|
||||
"""递归的空间复杂度为 O(n)"""
|
||||
if n == 1: return
|
||||
if n == 1:
|
||||
return
|
||||
return recur(n - 1)
|
||||
```
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user