
(d) The compression of spring is maximum when velocities of both blocks $A$ and $B$ is same. Let it be $v_{0}$, then from conservation law of momentum
$mv = mv_{0} + mv_{0} = 2mv_{0} \Rightarrow v_{0} = \frac{v}{2}$
$\therefore$ kinetic energy of $A - B$ system at that stage
$= \frac{1}{2}(m + m) \times \left( \frac{v}{2} \right)^{2} = \frac{mv^{2}}{4}$
Further loss in KE> = gain in elastic potential energy
$ie$, $\frac{1}{2}mv^{2} - \frac{1}{4}mv^{2} = \frac{1}{4}mv^{2} = \frac{1}{2}kx^{2}$
$\Rightarrow \ x = v\sqrt{\frac{m}{2k}}$