Home C C++ Java Python Perl PHP SQL JavaScript Linux Online Test Forum

Home » Forum » x-Forum » Question

How to find if Link List is circular

How to find if Link List is circular in C programming. Please share example using structure, functions, header file.

Posted by david 2019-01-24 17:10:50

Floyd’s Cycle-Finding Algorithm:
This is the fastest method. Traverse linked list using two pointers.  Move one pointer by one and other pointers by two.  If these pointers meet at same node then there is a loop.  If pointers do not meet then linked list doesn’t have loop.


C++ user image sanjay.vaniya posted 2019-04-08 01:03:38

Please login to comment

Log In

Ask New Question