in both the case since there is no external force acting on the system
so acc of com will be zero, that emplies velocity of com will be constant that emplies after collision it will be same to that it was before collision.
u1= initial velocity of mass m1
u2= initial velocity of mass m2
altough total kinetic energy of system in elastic collision will be constant, but in inelastic some kinetic energy get loss
Regards.