Here is an exercise (4.27) from Nielsen and Chuang and I found the answer (given in the figure below) online without any explanation. The question was to construct a circuit by seeing a matrix (given in the figure).
So I want to know what should be the thought process after seeing the matrix?