Skip to content

Conversation

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

Some issue here with missing helper methods. Otherwise not bad. Take a look at my comments and let me know what questions you have.

Thanks for getting this in.

current = @root
tree = []

return inorder_helper(current, tree)

Choose a reason for hiding this comment

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

Did you forget to commit inorder helper? Ditto for the other traversals

return height_helper(current, 1, 1)
end

def height_helper(node)

Choose a reason for hiding this comment

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

👍

# Time Complexity:
# Space Complexity:
# Time Complexity: O(n)
# Space Complexity: O(1)

Choose a reason for hiding this comment

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

Since you are doing recursion I would say this is O(log n) where n is the number of elements ,assuming it's a balanced tree. Remember doing recursion requires a stack!

# Time Complexity:
# Space Complexity:
# Time Complexity: O(log n)
# Space Complexity: O(1)

Choose a reason for hiding this comment

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

Since you are doing recursion here, this is O(log n) assuming the tree is balanced. Remember the system stack used by recursion.

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