A linked list class is given. we have to find whether it is circular or not? I have already find the question on this website but did not find any relevant answer.
Asked
Active
Viewed 486 times
-1
-
I don't believe this is question is Java specific. This may help: http://stackoverflow.com/questions/6482886/cycle-detection-with-the-hare-and-tortoise-approach or this http://en.wikipedia.org/wiki/Cycle_detection#Tortoise_and_hare – doctorlove Aug 24 '14 at 08:12
1 Answers
0
Without seeing the code for the list implementation, a quick test would be to see if the head pointer and last node pointers point to the same element. This information is indirectly accessible through the class iterator.

T-Dawg
- 9
- 2