-
Notifications
You must be signed in to change notification settings - Fork 44
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
Time - Hannah T #38
base: master
Are you sure you want to change the base?
Time - Hannah T #38
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.
Well done Hannah, thanks for getting this in. I like how you did bfs
, very compact. Solid work.
# Time Complexity: O(Log n) | ||
# Space Complexity: O(1) | ||
def add(key, value) |
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(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(Log n) | ||
# Space Complexity: O(n) | ||
def inorder |
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.
👍 , interesting choice to make an inner function. That's a very JavaScripty thing to do here.
# Time Complexity: O(Log n) | ||
# Space Complexity: O(n) | ||
def preorder |
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(n) | ||
|
||
def postorder |
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 |
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 and space complexity?
def innerfunc(node) | ||
return 0 if node.nil? | ||
return 1 if !node.left && !node.right | ||
return [innerfunc(node.left) + 1, innerfunc(node.right) + 1].max |
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.
Very slightly more compact
return [innerfunc(node.left) + 1, innerfunc(node.right) + 1].max | |
return [innerfunc(node.left), innerfunc(node.right)].max + 1 |
# Time Complexity: | ||
# Space Complexity: | ||
def bfs |
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 with BFS. Time and space complexity?
No description provided.