Motion of bodies connected by springs Two blocks $A$ and $B$ of masses $m$ are connected by a spring of length $L$ and spring constant $k$. They rest on the frictionless floor. Another body of mass m moving with velocity $v$ collides elastically with $A$. The spring compresses and at maximum compression velocity of both $A$ and $B$ are $v/2$ each. Why did these bodies get equal velocities?
 A: Assuming that the collision takes place over a period of time much shorter than the period of oscillation of the two mass & spring system the collision can be treated as the moving mass, velocity $v$ mass $m$, hitting head on a stationary mass of equal mass.
This results in the originally moving mass stopping and the originally stationary mass moving off with velocity $v$.
This can be shown by using the conservation of linear momentum (no external forces acting) and the conservation of kinetic energy (elastic collision).  
The two mass & spring system has momentum $mv$ and so the velocity of their centre of mass must be $\frac v 2$ and it will stay that value because there are no external forces.  
Because the total momentum in the centre of mass frame must be zero the velocities of the two masses in the centre of mass frame must always be equal in magnitude but opposite in direction.
When the spring has a maximum compression the two masses must be at rest in the centre of mass frame so they must be moving at the speed of the centre of mass, $\frac v2$, relative to the ground.
A: Welcome to StackExchange!
To answer your question, apply conservation of momentum. I will assume the collision gave the block A some velocity v. Now the initial momentum of the system would be p=mv.
Suppose at some time, lets say the block A now has a speed u. By momentum conservation, you would get speed of block B to me v-u.
At maximum compression of spring, we will have spring to hold maximum potential energy. This means the kinetic energy of block system will be minimum. Which means
Kinetic Energy=0.5*m*(u)^2+0.5*m*(v-u)^2.
If you use derivative methods to minimize the kinetic energy, you will get u=v/2.
A: You should note that the velocities are equal at maximum compression. This have nothing to do with conservation laws (the fact that the value at that point is v/2 comes from conservation laws but the fact that the two speeds are equal do not).
Imagine that initially (right after collision) A moves and B is still at rest. So as A moves relative to B the distance between them decreases and the spring compresses. As time passes A slows down and B gains speed but as long as the two speeds are different A still approaches B and the spring keeps compressing. This happens until the two speeds become equal. At that point the two bodies are neither approaching nor departing each other and the spring length is stationary. After that point B moves faster than A and the spring's length starts to increase.
So, in summary, if the two speeds are not equal the spring is not at maximum compression. Its length is either decreasing or increasing. 
