Math, asked by jaatryaan5729, 1 year ago

2. A binary matrix of n x m, you have to toggle any column k number of times so that you can get maximum rows having all 1

Answers

Answered by CarlynBronk
3

Solution:

Consider a matrix of order , 2 × n  or, 3 ×p,or n×m binary matrix that is only elements in the matrix are 0 and 1.

Now coming to ,2 × n  or, 3 ×p,or n×m matrix,if first column consist of only 1,and other entries in the matrix are 0,then if you toggle just once with (2×2),matrix in the first column, you will get , 2×2 matrix. having all entries 1.

Similarly, for (3×3) matrix having all entries in the first column as 1, if you toggle twice, you will get all rows having all 1.

For , 2 × n→Toggle with first column (n-1) times to get all rows having 1 ,if each element in first column is 1.

For, 3 × p→Toggle with first column (p-1) times to get all rows having 1,,if each element in first column is 1.

\begin{bmatrix} 1&0  &0 \\  1& 0 & 0\end{bmatrix}

it is 2 × 3 matrix.

If you perform this operation

C_{2}\rightarrow C_{1}+C_{2}\\\\ C_{3}\rightarrow C_{1}+C_{3}

that is number of columns is 3, so you have toggled twice the first column to get all rows having 1 as an entry.


Similar questions