Skip to content

Conversation

@sophearychiv
Copy link

No description provided.

Copy link

@CheezItMan CheezItMan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done, you hit the major learning goals here. The only big issue I see is that you didn't account for the system stack taking up memory in terms of your space complexity.

Remember if you're doing recursion the stack does take up memory space.

# Time Complexity:
# Space Complexity:
# Time Complexity: O(log n)
# Space Complexity: O(1)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually since you're doing a recursive solution the system stack will be of size O(log n) if the tree is balanced and O(n) otherwise.

Also your time complexity will be the same.

# Space Complexity:
# Time Complexity: O(n) where n is the number of nodes
# Space Complexity: O(n) where is is the length of the tree
def bfs

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Niiice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants