-
Notifications
You must be signed in to change notification settings - Fork 39
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
base: master
Are you sure you want to change the base?
Dianna T. #5
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.
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) |
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 of using Depth-First-Search to solve this .
end | ||
|
||
while !queue.empty? | ||
current = queue.shift |
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.
Just a note that .shift
is an O(n) operation, so it would impact your runtime.
Got both DFS and BFS working!