Let $M$ be an $n \times n$ matrix with each entry equal to either $0$ or $1$. Let $m_{i,j}$ denote the entry in row $i$ and column $j$. A diagonal entry is one of the form $m_{i,i}$ for some $i$. Swapping rows $i$ and $j$ of the matrix $M$ denotes the following action:we swap the values $m_{i,k}$ and $m_{j,k}$ for $k = 1, 2 ..... n$. Swapping two columns is defined analogously We say that $M$ is re-arrangeable if it is possible to swap some of the pairs of rows and some of the pairs of columns (in any sequence) so that, after all the swapping, all the diagonal entries of $M$ are equal to $1$.
(a) Give an example of a matrix $M$ that is not re-arrangeable, but for which at least one entry in each row and each column is equal to $1$.
(b) Give a polynomial-time algorithm that determines whether a matrix $M$ with $0-1$ entries is re-arrangeable.
I tried a lot but could not reach to any conclusion please suggest me algorithm for that.
Do a search for Hall's Marriage Theorem. Imagine each row is a man, each column is a woman, each $1$ represents a compatible couple, and the question is whether you can pair off the men and women into compatible couples. Hall's Marriage Theorem gives a simple necessary and sufficient condition.
Then think about $$\pmatrix{1&1&1\cr1&0&0\cr1&0&0\cr}$$