(639 Views)

Floyd’s Cycle Detection Algorithm is a pointer algorithm that makes use of only two pointers, which move through the given sequence at different speeds interval. The idea of algorithm is to move fast pointer twice as quickly as the slow pointer and the distance between the two increases by 1 at each step. If at some point both the points meet, we have a cycle in the list, else if we have reached the end of the list, no cycle is present. This algorithm is also called the “tortoise and the hare algorithm”.

Let's see a simple implementation of Floyd Cycle Detection Algorithm in Java.

1 UpvotesUpvote |
0 DownvotesDownvote |

- Fetch data from Excel file using Java Spring Web application [1495 Views]
- What Are Initial Capacity And Load Factor Of HashMap In Java [315 Views]
- Java Serialization with Externalizable and their difference [218 Views]
- How to check Mobile Number is Valid or not in java [213 Views]
- What is the difference between Stack and Queue in java? [276 Views]

- Knuth-Morris-Pratt (KMP) Substring Search Algorithm with Java Example [6877 Views]
- Pseudocode and Algorithm to find whether number is Armstrong Number or Not [6382 Views]
- How To Win Ludo King Game Every Time [6250 Views]
- error: Multiple commands produce error in Xcode 10 [4737 Views]
- Create Dynamic Pagination using Java Spring Boot, Hibernate and MySQL [3699 Views]