Ubuntu 16.04LTS extended display not working

The issue was with the nvidia graphics driver.This can be fixed by following the steps below :

1.Run sudo apt-get purge nvidia-*

2.Run sudo add-apt-repository ppa:graphics-drivers/ppa

3.Run sudo apt-get update

4.Run sudo apt-get install nvidia-364

Reboot and your graphics issue should be fixed.