Skip to content

Time - Ross#14

Open
syrosalynyu wants to merge 2 commits into
Ada-C13:masterfrom
syrosalynyu:master
Open

Time - Ross#14
syrosalynyu wants to merge 2 commits into
Ada-C13:masterfrom
syrosalynyu:master

Conversation

@syrosalynyu

Copy link
Copy Markdown

No description provided.

@CheezItMan CheezItMan left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice work, you hit the learning goals here Ross. Let me know if you have questions about my comments.

Comment thread lib/tree.rb
Comment on lines +19 to 21
# Time Complexity: o(log n) if it's balanced; worst case is o(n)
# Space Complexity: o(n)
def add(key, value)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 Space & Time complexities are both O(log n) unless the tree is unbalanced, in which case they are O(n).

Comment thread lib/tree.rb
Comment on lines +43 to 45
# Time Complexity: o(log n) if it's balanced; worst case is o(n)
# Space Complexity: o(n)
def find(key)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍 Space & Time complexities are both O(log n) unless the tree is unbalanced, in which case they are O(n).

Comment thread lib/tree.rb
Comment on lines +63 to 65
# Time Complexity: o(n)
# Space Complexity: o(n)
def inorder

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/tree.rb
Comment on lines +85 to 87
# Time Complexity: o(n)
# Space Complexity: o(n)
def preorder

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/tree.rb
Comment on lines +109 to 111
# Time Complexity: o(n)
# Space Complexity: o(n)
def postorder

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread lib/tree.rb
Comment on lines +132 to 134
# Time Complexity: o(log n)
# Space Complexity: o(n)
def height

Copy link
Copy Markdown

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) since you visit each node, and space complexity is O(log n) if the tree is balanced and O(n) if it's unbalanced.

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