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

Fire - blaine #28

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Fire - blaine #28

wants to merge 4 commits into from

Conversation

Blaine206
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.

Awesome work Blaine, this hits the learning goals.

I did have comments on time/space complexity. Let me know if you have questions.

Comment on lines +19 to +22
# Time Complexity: O(log n)
# Space Complexity: [O(1)-if it's a loop] - why do I wanna say O(n)?? help me.
# Try with a while loop
def add(key, value = nil)

Choose a reason for hiding this comment

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

👍 The time complexity is O(n) if the tree is balanced and O(log n) if it is balanced.
Since you're doing recursion in add_helper the space complexity is the same as the time.

Comment on lines +51 to 53
# 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.

👍 Ditto on space/time complexity

Comment on lines +71 to 74
# Time Complexity: O(n)
# Space Complexity: O(n)
# left-root-right
def inorder

Choose a reason for hiding this comment

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

👍

Comment on lines +90 to 93
# Time Complexity: O(n)
# Space Complexity: O(n)
# root-left-right
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 +107 to 110
# Time Complexity: O(n)
# Space Complexity: O(n)
# left-right-root
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 +124 to 126
# Time Complexity: O(n)^2
# Space Complexity: O(n)
def height

Choose a reason for hiding this comment

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

👍 The time complexity is O(n) (not n^2)

The space complexity is O(log n) if the tree is balanced or O(n) if it's not. The space complexity is basically the height of the tree.

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