Ultimate_Algorithms_Repository icon indicating copy to clipboard operation
Ultimate_Algorithms_Repository copied to clipboard

Floyd's Algorithm

Open codebloded opened this issue 3 years ago • 1 comments

Title or Name of the Algorithm *Floyd's Algorithm

Describe the algorithm Floyd's algorithm is used for detection and removal of a cycle in a linked list

codebloded avatar Jan 21 '21 20:01 codebloded

Title or Name of the Algorithm *Floyd's Algorithm

Describe the algorithm Floyd's algorithm is used for detection and removal of a cycle in a linked list

Floyd's Algorithm #336

Title of the Algorithm Floyd's Algorithm

Describe the algorithm Floyd’s algorithm, also known as the Hare-Tortoise algorithm, is a pointer algorithm that uses only two pointers, moving through the sequence at different speeds. This algorithm is used to find a loop in a linked list. It uses two pointers one moving twice as fast as the other one. [The faster one is called the fast pointer and the other one is called the slow pointer]

While traversing the linked list one of these things will occur- The Fast pointer may reach the end (NULL) this shows that there is no loop in the linked list. [The Fast pointer again catches the slow pointer at some time therefore a loop exists in the linked list]

shivanshu814 avatar May 22 '23 03:05 shivanshu814