Skip to content
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

Rock - lin #52

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Rock - lin #52

wants to merge 1 commit into from

Conversation

lzhang39
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 Lin, you hit the learning goals here. Well done. I did leave some minor comments. Take a look and let me know what questions you have.

Comment on lines +16 to +18
# Time Complexity: O(log(n))*assumes all balanced tree
# Space Complexity: O(1)
def add(self, key, value=None):

Choose a reason for hiding this comment

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

👍 However due to the recursive call stack this is O(log n) for space complexity (if the tree is balanced and O(n) otherwise).

Comment on lines +33 to +35
# Time Complexity: O(log(n))
# Space Complexity: O(1)
def find(self, value):

Choose a reason for hiding this comment

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

👍 Similar issues with space complexity.

Comment on lines +47 to 49
# Time Complexity: O(logn)
# Space Complexity: O(n)
def inorder(self):

Choose a reason for hiding this comment

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

👍 Since you hit each node and make a list the of all the nodes in the tree the time and space complexity is O(n)

Comment on lines +63 to 65
# Time Complexity: O(logn)
# Space Complexity: O(n)
def preorder(self):

Choose a reason for hiding this comment

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

👍 Similar issues to time/space complexity

Comment on lines +79 to 81
# Time Complexity: O(logn)
# Space Complexity: O(n)
def postorder(self):

Choose a reason for hiding this comment

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

👍 Similar issues to time/space complexity

Comment on lines +95 to 97
# Time Complexity: O(logn)
# Space Complexity: O(1)
def height(self):

Choose a reason for hiding this comment

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

👍 However the space complexity is O(log n) due to the recursive call stack.

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