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

Dianna T. #5

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

Dianna T. #5

wants to merge 10 commits into from

Conversation

dtingg
Copy link

@dtingg dtingg commented Apr 5, 2020

Got both DFS and BFS working!

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.

Really well done, you did the work, both ways. Well done.

# Depth First Search
# Time: O(n + e) where n is the number of nodes in the graph and e is the number of edges.
# Space: O(n) where n is the number of nodes in the graph.
def possible_bipartition(dislikes)

Choose a reason for hiding this comment

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

Nice work of using Depth-First-Search to solve this .

end

while !queue.empty?
current = queue.shift

Choose a reason for hiding this comment

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

Just a note that .shift is an O(n) operation, so it would impact your runtime.

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