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 - Roshni #30

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

Fire - Roshni #30

wants to merge 2 commits into from

Conversation

roshni-patel
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.

Nice work Roshni, you hit the learning goals here. Well done.

Comment on lines +19 to +21
# Time Complexity: O(log n) for balanced, O(n) for unbalanced
# Space Complexity: O(log n) for balanced, O(n) for unbalanced
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.

👍

Comment on lines +40 to +65
# iterative add helper
# def add_helper(current, key, value)
# added_to_tree = false

# until added_to_tree
# if key <= current.key
# next_node = current.left
# if next_node.nil?
# new_node = TreeNode.new(key, value)
# current.left = new_node
# added_to_tree = true
# else
# current = current.left
# end
# else
# next_node = current.right
# if next_node.nil?
# new_node = TreeNode.new(key, value)
# current.right = new_node
# added_to_tree = true
# else
# current = current.right
# end
# end
# end
# end

Choose a reason for hiding this comment

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

Nice!

Comment on lines +69 to 71
# Time Complexity: O(log n) for balanced, O(n) for unbalanced
# Space Complexity: O(log n) for balanced, O(n) for unbalanced
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 +106 to 108
# Time Complexity: O(n) to visit all nodes
# Space Complexity: O(n) values array depends on how many nodes there are
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 +122 to 124
# Time Complexity: O(n) to visit all nodes
# Space Complexity: O(n) values array depends on how many nodes there are
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 +138 to 140
# Time Complexity: O(n) to visit all nodes
# Space Complexity: O(n) values array depends on how many nodes there are
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 +154 to 156
# Time Complexity: O(n) to visit all the nodes
# Space Complexity: O(log n) if balanced, O(n) if unbalanced
def height

Choose a reason for hiding this comment

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

👍

Comment on lines +170 to 173
# Time Complexity: O(n^2) due to use of .shift
# Space Complexity: O(n)
# Solution from class
def bfs

Choose a reason for hiding this comment

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

👍 This should work, and good insight with the .shift's affect on the time 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