0% completed
Solution explanation incorrect and does not match python code.
Lee
Mar 25, 2024
The solutions explanation would lead you to believe that you need only check if the two nodes connected by the edge belong to the same subset. If they do, the graph is not bipartite.
This is not correct though, as the code that matches this description fails. Then, looking at the solution code in python, you see some tricky stuff is happening with the first neighbor in the set of neighbors for each node. This is not explained at all in the solution. It's not clear how or why this code succeeds at detecting whether or not the graph is bipartite.
4
0
Comments
Silencer312 2 years ago
You are right, some of the solutions on here aren't explained correctly or just wrong. Also some time complexity discussions are questionable. For this specific question, To use union find, we basically need to make sure that the neighbors of the current node are not in...
Ike Nwankwoa year ago
also wouldn't the time complexity be O(v+e)
Divyanshu Varma6 months ago
The given DSU solution for C++ is incorrect! Better use BFS/DFS for this 2-coloring (bipartite) problem.
On this page