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:
Nan Lei 2024-03-25 01:53:21 +08:00 committed by GitHub
parent 739ee24751
commit 55db99ab18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 4 deletions

View file

@ -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)
```

View file

@ -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)
```