mirror of
				https://github.com/krahets/hello-algo.git
				synced 2025-11-04 22:28:40 +08:00 
			
		
		
		
	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:
		@ -476,9 +476,10 @@ Consider the following code, the term "worst-case" in worst-case space complexit
 | 
				
			|||||||
        for _ in range(n):
 | 
					        for _ in range(n):
 | 
				
			||||||
            function()
 | 
					            function()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def recur(n: int) -> int:
 | 
					    def recur(n: int):
 | 
				
			||||||
        """Recursion O(n)"""""
 | 
					        """Recursion O(n)"""""
 | 
				
			||||||
        if n == 1: return
 | 
					        if n == 1:
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
        return recur(n - 1)
 | 
					        return recur(n - 1)
 | 
				
			||||||
    ```
 | 
					    ```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -475,9 +475,10 @@
 | 
				
			|||||||
        for _ in range(n):
 | 
					        for _ in range(n):
 | 
				
			||||||
            function()
 | 
					            function()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def recur(n: int) -> int:
 | 
					    def recur(n: int):
 | 
				
			||||||
        """递归的空间复杂度为 O(n)"""
 | 
					        """递归的空间复杂度为 O(n)"""
 | 
				
			||||||
        if n == 1: return
 | 
					        if n == 1:
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
        return recur(n - 1)
 | 
					        return recur(n - 1)
 | 
				
			||||||
    ```
 | 
					    ```
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user