-
Notifications
You must be signed in to change notification settings - Fork 44
Sockets - Grace #31
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
base: master
Are you sure you want to change the base?
Sockets - Grace #31
Conversation
There was a problem hiding this 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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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.
No description provided.