-
Notifications
You must be signed in to change notification settings - Fork 64
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 - Juliana Tree exercise complete #49
base: master
Are you sure you want to change the base?
Conversation
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.
All the given methods work, with a little strangeness as to why you're creating new trees for some of the traversals.
I'm glad things make more sense now.
# Time Complexity: O(log n) | ||
# Space Complexity: O(1) | ||
def add(self, key, value = None): |
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.
👍
# Time Complexity: O(log n) | ||
# Space Complexity: O(1) | ||
def find(self, key): |
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.
👍
# Time Complexity: O(n) | ||
# Space Complexity: O(n) | ||
def inorder(self): |
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.
👍
def inorder(self): | ||
pass | ||
trees = [] | ||
return self.awesome_helper_inorder(self.root, trees) |
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.
Glad you have an awesome helper
left = Tree() | ||
left.root = self.root.left | ||
right = Tree() | ||
right.root = self.root.right |
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.
Why do you make a new Tree
here? That seems excessive, but it does work.
# Time Complexity: O(log n) | ||
# Space Complexity: O(n) | ||
def height(self): |
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.
👍 The time complexity here is O(n) because you visit each node.
# Time Complexity: O(n) | ||
# Space Complexity: O(n) | ||
def postorder(self): |
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.
👍 With similar issues with preorder
What a doozy! By the end, it made more sense.