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

Ports - Ngoc #29

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

Ports - Ngoc #29

wants to merge 2 commits into from

Conversation

lebaongoc
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, 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)

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)

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)

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)

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

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

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