From 55db99ab181143169c341189e40c5c050d7fb3e0 Mon Sep 17 00:00:00 2001 From: Nan Lei Date: Mon, 25 Mar 2024 01:53:21 +0800 Subject: [PATCH] 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 --- docs-en/chapter_computational_complexity/space_complexity.md | 5 +++-- docs/chapter_computational_complexity/space_complexity.md | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs-en/chapter_computational_complexity/space_complexity.md b/docs-en/chapter_computational_complexity/space_complexity.md index 726e9346e..6e7be8104 100644 --- a/docs-en/chapter_computational_complexity/space_complexity.md +++ b/docs-en/chapter_computational_complexity/space_complexity.md @@ -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) ``` diff --git a/docs/chapter_computational_complexity/space_complexity.md b/docs/chapter_computational_complexity/space_complexity.md index 083f1c1fe..a6534fbe8 100755 --- a/docs/chapter_computational_complexity/space_complexity.md +++ b/docs/chapter_computational_complexity/space_complexity.md @@ -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) ```