Skip to content

Kayla - Pine#38

Open
khuddleup wants to merge 4 commits intoAda-C16:masterfrom
khuddleup:master
Open

Kayla - Pine#38
khuddleup wants to merge 4 commits intoAda-C16:masterfrom
khuddleup:master

Conversation

@khuddleup
Copy link

No description provided.


# Additionally, if the next dog is NOT group 1, add the current dog to group 2
# But if the next dog is NOT in group 1 then add it to group 2
else:
Copy link
Author

Choose a reason for hiding this comment

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

^^^ This shold actually say, if the current dog IS in group 1, then check to see if the next dog is also in group 1, and if it it is return false, cuz aint no way these dogs will get along. But if the next dog is NOT in group 1, then add it to group 2.

Copy link

@kyra-patton kyra-patton left a comment

Choose a reason for hiding this comment

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

🐾🐶 Very nice BFS implementation, Kayla. Really appreciate you working through this! Let me know what questions you have.

🟢

Time Complexity: ?
Space Complexity: ?
Time Complexity: O(n+e) number of nodes in the graph and e is the numbner of edges
Space Complexity: O(n) storing 4 variables? Checked, G1, G2, queue. drop the constant

Choose a reason for hiding this comment

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

✨ Yes, because queue, checked, group1, and group2 each can hold at most n elements, where n is the number of nodes (or dogs) in dislikes. Nice work!

Comment on lines +31 to +32
if not dislikes[current]:
queue.append(current + 1)

Choose a reason for hiding this comment

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

Creative way to handle disconnected nodes in the graph!

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