Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   Q related to CLL (http://www.go4expert.com/forums/q-related-cll-t2166/)

lakshmikanth 8Dec2006 09:21

Q related to CLL
 
How can we write a program to know whether a given linked list is circular or not . please reply me with the program

DaWei 8Dec2006 10:39

Re: Q related to CLL
 
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.

shabbir 8Dec2006 10:41

Re: Q related to CLL
 
If you reach the head node while traversing the Linked list then you can safely assume its circular.


All times are GMT +5.5. The time now is 04:30.