A linear-time algorithm for finding Hamiltonian