Define the distance of A to B as x.
Average speed is total distance divided by total time taken. We already know that since the man walks from A to B and then B to A he travelled a distance of 2x. All we need to calculate is the total time taken.
Calculate the times taken.
A to B:
B to A:
Calculate total time and then average speed.
Total time taken,