Q related to CLL

Newbie Member
8Dec2006,09:21   #1
lakshmikanth's Avatar
How can we write a program to know whether a given linked list is circular or not . please reply me with the program
Team Leader
8Dec2006,10:39   #2
DaWei's Avatar
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.
Go4Expert Founder
8Dec2006,10:41   #3
shabbir's Avatar
If you reach the head node while traversing the Linked list then you can safely assume its circular.