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

Ruthie Newman, C.15, Paper, Bipartition-Graph #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

RuthieRNewman
Copy link

Implementation of possible_bipartition method.

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 Ruthie, thanks for getting this in.

Comment on lines 5 to 16
def possible_bipartition(dislikes):
""" Will return True or False if the given graph
can be bipartitioned without neighboring nodes put
into the same partition.
Time Complexity: ?
Space Complexity: ?

Time Complexity: O(1) to access the adjacency list, o(1) to iterate through the dog_dict hash map used to
organize the dislikes data into a more accessible format(w/out empty indices), o(n) to iterate through each value list of the
dictionary, which is dependent on the size of the input.

Space Complexity: O(n) for new varaibles created (visited list, dictionary) b/c the space occupied is dependent on the input.
O(E) for the adjacency list because each node in the dislikes array has a list of edges.
"""

Choose a reason for hiding this comment

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

👍 Nice DFS Solution.

However the time complexity would be O(VE) where V is the number of vertices and E the number of edges.

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