As the quantities have been given in CGS units, therefore, answers have been worked out in same units.
Values used
Latent Heat of fusion of water #= 79.5cal//gm =333 kJ//kg#
Specific heat of water#=1cal//gm=4.19kJ//kg#
Latent heat exchanged for change of state #Q_l=mL#,
where #m and L# are mass and latent heat of the substance.
Amount of heat exchanged is given as #DeltaQ=msDeltat#,
where #m# is the mass, #s# is the specific heat and #Deltat# is change in temperature.
Case 1.
Let the final temperature of the mixture be water at #t_1^o C#.
Heat lost by 5gm of water at #90^oC# to become Water at #t_1^o C# is given as
#DeltaQ_(lost)=5 times 1times (90-t_1^o)#
Simlarly heat gained by ice at #0^o# to water at #t_1^o C# is given as
#DeltaQ_(gai n ed)=#heat gained by #5gm# Ice at #0^oC# for the change of state#+#Heat gained by 5gm of water at #0^oC# to become Water at #t_1^o C#
#DeltaQ_(gai n ed)=5 times 79.5+ 5 times 1 times (t_1^o-0)#
Since, #DeltaQ_(lost)= Delta Heat_(gai n ed)#
#5 times 1times (90-t_1^o)=5 times 79.5+ 5 times 1 times (t_1^o-0)#
#implies (90-t_1^o)= 79.5+ t_1^o#
#implies 2t_1^o= 10.5^oC#
Case 2.
Let the final temperature of the mixture be water at #t_2^o C#.
Heat lost by 500gm of water at #90^oC# to become Water at #t_2^o C# is given as
#DeltaQ_(lost)=500 times 1times (90-t_2^o)#
As in Case 1. heat gained by ice at #0^o# to water at #t_2^o C# is given as
#DeltaQ_(gai n ed)=#heat gained by #5gm# Ice at #0^oC# for the change of state#+#Heat gained by 5gm of water at #0^oC# to become Water at #t_2^o C#
#DeltaQ_(gai n ed)=5 times 79.5+ 5 times 1 times (t_2^o-0)#
Since, #DeltaQ_(gai n ed)= Delta Heat_(lost)#
#500 times 1times (90-t_2^o)=5 times 79.5+ 5 times 1 times (t_2^o-0)#
#implies 100(90-t_2^o)= 79.5+ t_2^o#
#implies 101t_2^o= 8920.5^oC#