using the hare and tortoise algorithm for linked lists