Is there any tutorial for learning minimum vertex cover properly?
Could u please explain what are your vertices and edges?
I thought this :
vertices: each set bit i,and then n array elements
edges:
set bit i:to all array elements whose ith bit is set
but for the example given above,
we have edges:
0 th bit set:1,3,5
1 st bit set:2,3
2 nd bit set:4,5
but here the minimum vertex cover is {0th bit set,1st bit set,2nd bit set}
I know i am missing something,could u please correct me?
Yes you are right sadly it doesnt work. I have an alternate solution though. Let me think on it a bit before posting here because it might also be wrong xD
sorry this doesnt work. Trying to think of some alternate approach
It seems, like it can be solved using min-cost-max-flow. Let’s build net with 4 layers:
1 - There will be only the Source vertex.
2 - There will be vertex for all a_i.
3 - There will be all bits from 1 to 19 (maximal bit, which can be in answer).
4 - There will be only the Sink vertex.
Now let’s build the edges.
Edges from 1st layer to 2nd layer: make and edge from Source to every a_i, which is on the second layer, for the chosen a_i the edge will be with capacity = number\ of\ ones\ in\ binary\ representation\ of\ a_i, and cost = \frac{1}{number\ of\ ones\ in\ a_i} .
Edges from 2nd layer to 3rd layer: for the chosen vertex a_i for the bits, which is set in a_i, make the edge to corresponding its bit vertex on the 3rd layer with following properties: capacity = 1, and cost = 0.
Edge from 3rd to 4th layer: from every vertex on 3rd layer make an edge to Sink vertex with capacity = 1 and cost = 0.
You are welcome to correct me, if I’m wrong. Also I can write code, if required.
Is the question link active now?