This is a classic question on Speed, time, & distance.
1. When time traveled in each segment is constant, then average speed is simple mean of speeds.
2. When distance traveled in each segment is constant, then average speed is reciprocal of simple mean of reciprocal of speeds. It is basically called Harmonic mean.
So this question falls in the category of 2.
=> So, average speed = Reciprocal of mean of reciprocals of 40 & 50.
=> Average speed = Reciprocal of mean of 1/40 & 1/50.
=> Average speed = Reciprocal of (1/40 + 1/50)/2 = Reciprocal of (5+4)/400 = 44 4/9 .
Hope this helps