Skip to content

Cedar - Laurel S. #35

Open
paperbackwriter2 wants to merge 2 commits intoAda-C16:masterfrom
paperbackwriter2:master
Open

Cedar - Laurel S. #35
paperbackwriter2 wants to merge 2 commits intoAda-C16:masterfrom
paperbackwriter2:master

Conversation

@paperbackwriter2
Copy link

No description provided.

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.

🐾🐶 Nice BFS solution, Laurel. I left a few comments and suggestions below. Let me know what questions you have.

🟢

into the same partition.
Time Complexity: ?
Space Complexity: ?
Time Complexity: O(n * m) where n is the number of nodes/dogs

Choose a reason for hiding this comment

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

⏱ Time complexity will actually be O(n + m) because you traverse each node and each edge exactly once. O(n*m) would mean that you traverse all the edges in the entire graph for each node in the graph.

Space Complexity: ?
Time Complexity: O(n * m) where n is the number of nodes/dogs
and m is the number of edges
Space Complexity: O(n)

Choose a reason for hiding this comment

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

Comment on lines +13 to +21
def createGraph(nodes):
graph = {}
for index, edge in enumerate(nodes):
graph[index] = []
for neighbor in edge:
graph[index].append(neighbor)
return graph

graph = createGraph(dislikes)

Choose a reason for hiding this comment

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

Totally fine to do this, I just want to note that dislikes is already considered an adjacency list. Adjacency lists can be represented as either a list of lists where the nodes are represented by the indices and the edges are the values(which is what we provide), or as a dictionary where the nodes are the keys and the values are the edges.

Comment on lines +31 to +32
if group == visited[dog]:
continue

Choose a reason for hiding this comment

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

Is there a way you might refactor your code to eliminate the continue statement?

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