(a) Let $m_{1},m_{2}$ be mass of bullet and gun and $u_{1},u_{2}$ be their initial velocities and $v_{1}$ and $v_{2}\ $be their final velocities. From law of conservation of momentum.
$m_{1}u_{1} + m_{2}u_{2} = m_{1}v_{1} + m_{2}v_{2}$
$Given,\ m_{1} = 5\ g = 5 \times 10^{- 3}\ kg,\ m_{2} = 5$ kg
$u_{1} = 0,\ u_{2} = 0\ (at\ rest),\ v_{1} = 500\ {ms}^{- 1}$
$\therefore\ \ m_{1} \times 0 + m_{2} \times 0 = 5 \times 10^{- 3} \times 500 + 5 \times v_{2}$
$\Longrightarrow \ \ \ v_{2} = - \frac{2.5}{5} = - 0.5\ {ms}^{- 1}$