-
-
Notifications
You must be signed in to change notification settings - Fork 195
[SAM] Week 3 solutions. #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -0,0 +1,29 @@ | |||
# Time complexity : O(n*m) | |||
# Space complexity : Space complexity: O(h) h is the height of the call stack during the recursive traversal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
흠... 모든 재귀 알고리즘에 해당하는 말이긴 한데, 이걸 가지고 공간 복잡도 "분석"을 했다라고 말할 수 있는지 의문이 들어요. 분석이 아니라 그냥 일반적인 사실을 말씀하신 느낌입니다.
시간 복잡도처럼 입력으로 들어온 두 개의 트리에 들어 있는 노드의 개수로 수식을 만들어야 하지 않을까요? 그리고 좀 더 구체적으로 이 둘 중에서 어떤 트리의 높이에 비례하는지, 아니면 둘 다 영향을 주는지에 대해서 분석을 해주는 것이 더 좋을 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
설명 더 구체적으로 반영해서 다시 푸시하겠습니다! 피드백 감사드립니다. 다시 보니 너무 빈약했네요ㅜㅜ
climbing-stairs/samthekorean.py
Outdated
@@ -0,0 +1,18 @@ | |||
# Time complexity : O(n) | |||
# Space complexity : O(n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space Complexity가
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
오타인 것 같습니다. 이따 다시 푸시하겠습니다!
b095aa1
to
9e15b25
Compare
@@ -0,0 +1,29 @@ | |||
# Time complexity: O(n*m) | |||
# Space complexity: O(h) where h is the depth of the root tree. This is due to the recursive calls, which generate the call stack during traversal. In the worst case of a skewed tree, the space complexity can reach O(n). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
subRoot
는 공간 복잡도에 전혀 영향을 안 준다는 분석인 것 같은데, 제가 맞게 이해하고 있는 걸까요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네 제가 적은 건 이해하신게 맞습니다. 이 문제에서 공간분석이 애매하다고 느껴서 알고달래에 분석해주신 것 보니 이제 왜 틀렸는지 이해가 갑니다. 다시 수정해서 올리겠습니다!
@@ -0,0 +1,29 @@ | |||
# Time complexity: O(n*m) | |||
# Space complexity: O(r + s) isSubtree() method is internally calling isSameTree() so the total depth of the stack is sum of isSubtree() call stacks and isSameTree()'s call stacks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Finally 💯!
No description provided.