Skip to content

Commit b7c826b

Browse files
authored
Update Space Complexity in subtree-of-another-tree
1 parent 4c3026c commit b7c826b

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

subtree-of-another-tree/bhyun-kim.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
The is_identical function has a time complexity of O(m).
2929
Therefore, the overall time complexity is O(n*m).
3030
31-
Space complexity: O(n)
32-
Where n is the number of nodes in the tree.
33-
The space complexity is O(n) because of the recursive calls to the depth_first_search function.
31+
Space complexity: O(m+n)
32+
Where n is the number of nodes in the tree and m is the number of nodes in the subtree.
33+
The space complexity is O(m+n) because of the recursive calls to the depth_first_search function
34+
and is_identical.
3435
"""
3536

3637

0 commit comments

Comments
 (0)