Displacement is the shortest distance between starting and ending point.
from the starting point, 50 m north and 20 m south, net is 50-20 =30 m north
and to east it is 40m
it forms a right angled triangle with 30m and 40m as sides.
whose hypotenuse is sqrt(30^2 + 40^2) = 50m
so the net displacement is 50m