Answer
$P=\begin{bmatrix} 1&0&0&0&0 \\ 2/3&0&1/3&0&0\\0&2/3&1/3&0&0\\0&0&0&1&0 \\ 0&0&1/2&1/2&0\end{bmatrix}$
Work Step by Step
We will write the $ij$th entry of $P$ as the probability of transition from the state $i$ to $j$ as follows:
$P_{11}=1\\ P_{21}=\dfrac{2}{3} \\ P_{23}=\dfrac{1}{3} \\ P_{32}=\dfrac{2}{3}\\P_{33}=\dfrac{1}{3}\\ P_{44}=1\\P_{53}=\dfrac{1}{2}\\P_{54}=\dfrac{1}{2}$
Therefore, we have:
$P=\begin{bmatrix} 1&0&0&0&0 \\ 2/3&0&1/3&0&0\\0&2/3&1/3&0&0\\0&0&0&1&0 \\ 0&0&1/2&1/2&0\end{bmatrix}$