Given data:
The spring's rest length is x=30 cm.
The compressed length of spring is x'=10 cm.
The displacement in the spring will be,
The slope of the given graph will be equal to the spring stiffness that can be calculated as,
The energy observed by the spring will be equal to the kinetic energy of the block. We can equate both to calculated the kinetic energy of the block,
Thus, the kinetic energy of the block is 12 J.