Skip to content

Water - Kareha - #19

Open
agesak wants to merge 9 commits into
Ada-C14:masterfrom
agesak:master
Open

Water - Kareha#19
agesak wants to merge 9 commits into
Ada-C14:masterfrom
agesak:master

Conversation

@agesak

@agesak agesak commented Apr 2, 2021

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 Kareha, you hit the learning goals here. Well done.

Comment thread lib/tree.rb
Comment on lines +19 to +21
# Time Complexity: O(logn)
# Space Complexity: O(logn)
def add(key, value = nil)

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/complexities are correct if the tree is balanced and O(n) if unbalanced.

Comment thread lib/tree.rb
Comment on lines +42 to 44
# Time Complexity: O(logn)
# Space Complexity: O(logn)
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.

👍 The time/complexities are correct if the tree is balanced and O(n) if unbalanced.

Comment thread lib/tree.rb
Comment on lines +59 to 61
# 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 +76 to 78
# 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 +93 to 95
# 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 +110 to 112
# Time Complexity: O(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 space complexity is O(n) if the tree is unbalanced and O(log n) if the tree is balanced.

Comment thread lib/tree.rb
Comment on lines +126 to 128
# Time Complexity: O(n*m)
# Space Complexity: O(n)
def bfs

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Because you are using .shift the time complexity is O(n^2), otherwise well done.

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