Source: https://archive.nptel.ac.in/content/storage2/courses/117101004/downloads/module5 and 6-problems.pdf