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>
pull/1170/head
Nan Lei 8 months ago committed by GitHub
parent 739ee24751
commit 55db99ab18
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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…
Cancel
Save