1. Engineering
  2. Computer Science
  3. 5 20 points recall the quothare and tortoisequot or pointer...

Question: 5 20 points recall the quothare and tortoisequot or pointer...

Question details

5. (20 points) Recall the hare and tortoise (or pointer chasing) algorithm we learned in class for cycle-detection in singly inked list: in each iteration, the tortoise pointer moves one step ahead and the hare pointer moves two steps ahead. (a) Suppose there are 100 nodes before entering the cycle, and the cycle consists of 17 nodes. Determine the number of iterations it takes the tortoise and the hare to meet (b) If there are L nodes before entering the cycle, which consists of C nodes. Express the number of iterations it takes the tortoise and the hare to meet in terms of L and C

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution