-
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
Brittany- Binary Search Tree #59
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.
Nice work Brittany, you hit all the learning goals here. Well done.
if val == None: | ||
val = key | ||
|
||
self.key = key | ||
self.value = val | ||
self.left = None | ||
self.right = None | ||
|
||
|
||
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.
👍 Nice recursive solution
return self.right | ||
return self.right.add(key, value) | ||
|
||
def inorder(self, list): |
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.
👍
if self.right is not None: | ||
self.right.inorder(list) | ||
|
||
def preorder(self, list): |
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.
👍
if self.right is not None: | ||
self.right.preorder(list) | ||
|
||
def postorder(self, list): |
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.
👍
"value": self.value | ||
}) | ||
|
||
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.
👍
# Time Complexity: | ||
# Space Complexity: | ||
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/space Complexity?
# Time Complexity: o(1) | ||
# Space Complexity: o(1) | ||
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.
👍 Time/space Complexity are both O(n)
# Time Complexity: o(n) | ||
# Space Complexity:0(n) | ||
|
||
# Time Complexity: | ||
# Space Complexity: | ||
def preorder(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.
👍 Time/space Complexity are both O(n)
# Time Complexity: 0(log n) | ||
# Space Complexity:o(1) | ||
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.
👍 Time/space Complexity are both O(n)
# Time Complexity: o(n) | ||
# Space Complexity:0(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.
👍
No description provided.