Saying 'Alhamdulillah' doesn't have any effect in the finality of the ghusl, so you can continue it and complete it after that if there is a part that you have missed. However, you can consider the ghusl to be complete and valid if the doubt arose after finishing the ghusl.
Sacrificing an animal such as a camel or cow is recommended, and one can do so on behalf of anybody deceased or living. Giving charity to needy people instead does not replace this recommended Sunnah of the Prophet (peace be upon him and his holy progeny), but one can undertake the sacrifice and give the meat to the needy people.