-
Notifications
You must be signed in to change notification settings - Fork 69
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
Lilly C16 #50
base: master
Are you sure you want to change the base?
Lilly C16 #50
Conversation
else: | ||
current = current.right | ||
|
||
# Time Complexity: o(1) |
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 for find will be O(log n) because you are still iterating through the BST, but only one half of it every time.
result.append({"key":current.key, "value":current.value}) | ||
result = self.inorder_helper(current.right, result) | ||
return result | ||
|
||
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.
👍
result.append({"key":current.key, "value":current.value}) | ||
result = self.preorder_helper(current.left, result) | ||
result = self.preorder_helper(current.right, result) | ||
return result | ||
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 Complexity: | ||
# Space Complexity: | ||
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 Complexity: | ||
# Space Complexity: | ||
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: | ||
# Time Complexity: O(log(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.
since you aren't recursively calling this, the space complexity is O(1) because no new memory is dependent upon the size of the input
current = current.right | ||
|
||
# Time Complexity: o(1) | ||
# 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.
since you aren't recursively calling this, the space complexity is O(1) because no new memory is dependent upon the size of the input
|
||
# Time Complexity: o(1) | ||
# Space Complexity: O(n) | ||
# search for a node in the tree | ||
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.
👍
No description provided.