Skip to content

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.


# 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