Proof. Choose a row having a minimum number of ones. Construct the matrix
M c as in the previous lemma. Each row will have no more than the number of ones
it originally contained plus the number of ones produced by complementation.
This at most doubles the total number of ones in the matrix.
M c can be constructed by scanning a list of the nonzero entries of M. The complementation
is easily performed using list handling techniques. Since each one
is only processed a fixed number of times, independent of the size of M, the total
time required is O(m + n + f).