(4) μg(M + m/2)
Mass m (or body A) will be on brink of moving when the force applied by the spring (i.e. kx) is just equal to the force of limiting friction between A and surface in contact. Therefore
kx = μmg .....(1)
x is the elongation in the spring
x = μmg/k .....(2)
The force will be minimum for M when it has no kinetic energy. Applying work energy theorem to M, we get
Work done = Change in kinetic energy