In the first case the friction force acts upwards along the rod; in the second it acts downwards.
Draw a diagram showing the forces acting on the ring in the first case, where the friction force acts up the rod. The four forces are:
normal contact force between the rod and the ring
weight of ring
tension in string
Then, since equilibrium is limiting,
From these, you can eliminate and to get:
Similarly if is the tension in the string when the ring is on the point of slipping upwards, you can show that
Now if the length of the segment of the rod between these two equilibrium positions is , then the change in length of the half of the string acting upon one of the rings is .
Using Hooke's Law: