Q related to CLL

lakshmikanth's Avatar, Join Date: Dec 2006
Newbie Member
How can we write a program to know whether a given linked list is circular or not . please reply me with the program
0
DaWei's Avatar, Join Date: Dec 2006
Team Leader
I won't write the program for you, but if you begin at the head, follow the links, and wind up back at the head, it's circular. If you run off the end of the world and dragons eat you (usually manifested by a NULL pointer), it's not circular. Tip: a simple pencil-and-paper representation of your problems is quite often effective. If you're not into destroying trees, an Etch-A-Sketch will do.
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
If you reach the head node while traversing the Linked list then you can safely assume its circular.