Source: https://people.clarkson.edu/~alexis/CS345/Notes/solutions.pdf