added the code which performs the swap between the adjacent elements