A binary matrix of size n
x n
is given.
At each step a function checks whether each row and each column of the given matrix has at least one 1
. If not, a purely random coordinate is chosen, say i, j
where 1 <= i
, j <= n
, and it is marked as 1
if it's 0
else the 1
is retained.
The process is repeated until the matrix has each row and column having at least one 1
.
Please tell what are the "expected number" of moves in this algorithm.