-
Notifications
You must be signed in to change notification settings - Fork 44
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
Ports - Ngoc #29
base: master
Are you sure you want to change the base?
Ports - Ngoc #29
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.
Nice work, I think your BFS method isn't working quite right, but otherwise nice work. You definitely hit the learning goals here.
end | ||
|
||
# Time Complexity: | ||
# Space Complexity: | ||
# Time Complexity: O(log n) |
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.
Actually the time complexity is O(n) because you visit every node.
end | ||
end | ||
|
||
# Time Complexity: O(log n) |
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.
O(n)
end | ||
end | ||
|
||
# Time Complexity: O(log n) |
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.
O(n)
return height_helper(current,height) | ||
end | ||
|
||
def height_helper(current, height) |
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.
Nice example of tail recursion
array = [] | ||
queue.push(@root) | ||
while !queue.empty? | ||
node = queue.pop |
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.
If you're doing pushes and pops, this isn't a Queue it's a stack. Thus This isn't going to be doing BFS
No description provided.