wu :: forums
« wu :: forums - Minimum lines to cover »

Welcome, Guest. Please Login or Register.
May 2nd, 2024, 10:09pm

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: towr, william wu, Grimbal, Icarus, ThudnBlunder, SMQ, Eigenray)
   Minimum lines to cover
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Minimum lines to cover  (Read 5520 times)
bazinga
Junior Member
**





   


Gender: male
Posts: 53
Minimum lines to cover  
« on: Oct 15th, 2012, 10:06pm »
Quote Quote Modify Modify

Given a 2-d array of 1' and 0's , give an algorithm to find minimum number of horizontal/vertical lines to cover all the zeros.
 
hidden:

For each position of zero check whether the number of 0's are greater in row or col. If row has more 0's draw one horizontal line otherwise if col has more 0's draw a vertical line. If 0's are equal in all rows and columns then arbitrarily break the tie.
Is this correct?  
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: Minimum lines to cover  
« Reply #1 on: Oct 16th, 2012, 10:28am »
Quote Quote Modify Modify

It doesn't give the optimal solution for
0 0 0
1 1 0
1 0 1
0 1 1
Three vertical lines will cover all zeroes, but if you start with a horizontal line (covering the greatest numbers of zeroes to start with), you still need three additional lines.
 
To start with, I'd look at each row/column that has only one 0, and then draw a line perpendicular through it. Because you need a line through that 0 anyway, and you may cross off extra ones this way. So it's a no-lose step. That doesn't provide a complete solution though.
Perhaps it'd work if, when you get stuck, you make a greedy choice (a line through most uncovered zeroes).
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
Aryabhatta
Uberpuzzler
*****






   


Gender: male
Posts: 1321
Re: Minimum lines to cover  
« Reply #2 on: Oct 17th, 2012, 9:26am »
Quote Quote Modify Modify

This is the minimum vertex cover problem for bi-partite graphs and has known fast solutions.
 
See this lecture: http://lucatrevisan.wordpress.com/2011/02/23/cs261-lecture14-algorithms- in-bipartite-graphs/
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board