In the simulation (or computer programming), the time step is a finite step.

The collision should have happened (It should occurred when R1+R2=d),

before the program detect those two ball collided ( R1+R2 > d, where d is the distance between two balls, and R1,R2 are the radius).

So we calculate the relative velocity in the direction between center of two balld, and estimate the time collision should have happened (dt). So we move the ball back to the moment when the collision should have occurred (let the time move backward by dt, or let particle move backward by v*dt !). Do the calculation for collision, and move time step dt forward again .