Understanding periodic quantum algorithms