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

Time - Hannah T #38

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

Conversation

stpatrickschild
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 Hannah, thanks for getting this in. I like how you did bfs, very compact. Solid work.

Comment on lines +22 to 24
# Time Complexity: O(Log n)
# Space Complexity: O(1)
def add(key, value)

Choose a reason for hiding this comment

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

👍

Comment on lines +50 to 52
# Time Complexity: O(Log n)
# Space Complexity: O(1)
def find(key)

Choose a reason for hiding this comment

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

👍

Comment on lines +66 to 68
# Time Complexity: O(Log n)
# Space Complexity: O(n)
def inorder

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.

Comment on lines +82 to 84
# Time Complexity: O(Log n)
# Space Complexity: O(n)
def preorder

Choose a reason for hiding this comment

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

👍

Comment on lines +98 to 101
# Time Complexity: O(Log n)
# Space Complexity: O(n)

def postorder

Choose a reason for hiding this comment

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

👍

Comment on lines +114 to 116
# Time Complexity:
# Space Complexity:
def height

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

Choose a reason for hiding this comment

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

Very slightly more compact

Suggested change
return [innerfunc(node.left) + 1, innerfunc(node.right) + 1].max
return [innerfunc(node.left), innerfunc(node.right)].max + 1

Comment on lines +127 to 129
# Time Complexity:
# Space Complexity:
def bfs

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?

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