This paper contains a description of an algorithm that uses the principle of inclusion and exclusion to determine the number of Hamiltonian paths in a given graph that have a given starting vertex and a given ending vertex, and it also contains a description of a similar algorithm to determine the number of Hamiltonian cycles in a given graph. The algorithms have an upper bound on time complexity of O(2n x n4) where n is the number of vertices in the graph. Also, the algorithms require only O(n3 log2 n) bits of storage space.