Learn basic concept of c , c++ and python programming in regularcodes.com
Find or Detect loop in a linked list
Suppose following data are inserting in linked list.
View insertion at beginning.
Use two pointer first_ptr and second_ptr. both are point to root (head) of linked list. And increment first pointer first_ptr by 2 and second_ptr by one if first_ptr are equal to second_ptr. That means loop are exist. Otherwise not.
Note that not given all step of execution process here.View How to insert linked list element and so on.
C program to find and detect loop of given linked list.