To determine how much a spring compresses when a block slides on a frictionless table, the principle of conservation of energy is applied. The kinetic energy of the moving block, represented as 1/2 mv^2, is converted into the potential energy stored in the compressed spring, given by 1/2 k x^2. The equation set up for this scenario equates the initial kinetic energy to the spring's potential energy at maximum compression. The correct relationship to use is that the kinetic energy of the block equals the spring energy when the block comes to rest. Thus, the compression distance x can be calculated using the formula derived from this energy conservation principle.