a bob of mass m of a long pendulum of lengtg Lis at a horizontal position p.when released ,it hits a ball of mass m placed at a position Q.assume the collision to be elastic .after hitting the ball at Q,the bob will attain a height ?

Where is Q located?

I'll explain how to do this, since I don't know enough about this problem.

Solve for the the bob's velocity right before it hits ball Q using energy equations: U(bob) = KE(bob) + U(Q). From here you can use your elastic equations to solve for the bob's velocity immediately after impact.

The bob will rise to it's maximum height when it's velocity is 0. Use a second conservation of energy statement: KE(bob after collision) = U.