Floyd's cycle finding algorithm