Find final speed of the block of mass m1.
Given, mass of first block, m1=2 kg
Mass of another block, m2=5 kg
Initial speed of first block, v1=10m/s
Initial speed of the second block, v2=3 m/s
Let at maximum compression both the blocks move with velocity V
By conservation of momentum
V=m1v1+m2v2m1+m2=5 m/s
Find maximum compression in spring.
The change in K.E.=kf−ki
ΔK.E.=12(m1+m2)V2−12m1v21−12m2v22
ΔK.E.=−35 J
This is stored as spring PE.
Therefore 12kx2=ΔK⇒x=√2ΔKk
on solving x=0.25 m=25 cm
Final answer: 25