Finding the length of a loop in linked list

In this article we will look at the method of finding the length of a loop in a linked list.For that you should be able to understand the floyd's loop detection algorithm.

Here is a picture that shows the cycle/loop in a linked list with a length of 4.


markup2-4


Before we move forward with the length of cycle in a linked list, let's look at the floyd's cycle finding algorithm.


floyd's cycle finding algorithm

Here is the working of the algorithm.



A slow and a fast pointer is used.
Slow pointer moves by o...
 •  0 comments  •  flag
Share on Twitter
Published on August 31, 2020 08:53
No comments have been added yet.