Part (a)
The object when comes down loses its potential energy which converts into kinetic energy. There won't be any loss in energy during conversion assuming there is no any kind of energy loss due to friction or air resistance.
So by the law of conservation of energy of the object in the above case.
Potential energy = Kinetic energy = Spring energy
=(m*g*h) = (1/2*m*v^2) = (1/2*k*x^2)
Where
m = mass of the object
g = acceleration due to gravity (almost = 10 (m/s^2))
h = height of the object
v = velocity of the object
k = spring constant expressed in (Force per unit compression displacement) ie., N/m.
x = displacement or compression of the spring in meters.
Potential energy = 3*10*5 = 150 joules
150 = 0.5*100*(x^2)
Sqrt (3) meter = x = 1.7321 m
Which is true only if the conversion of kinetic energy of the object to energy of the spring happens without any heat dissipation within spring.
Part (b)
After the object looses its energy to the spring the object looses it's velocity and comes to rest. This is when the spring starts loosing its energy (because the force of the object on the spring also becomes 0 when its velocity becomes 0 as there is no more possible deceleration) which is imparted back on to the object and assuming perfect conversion the object gains all of its kinetic energy back which converts back to potential energy without any loss and the object reaches back to the height of 5 meter.