DS2 Lab team-9
DS2 Lab team-9
Presented by :
● Sanjida Nafin Riya - 011202065
● Azmain Elahi - 011222289
● Tanjid Ahmad Anik - 0112230651
● Md. Nasir Khan Naim - 0112230676
Presented to :
Iftekharul Abedeen
Lecturer,
CSE, United International University.
Our Presentation Topic
In Data Structure,
❖ Detecting cycles in Linked Lists
Context of the Floyd’s ❖ Graph Algorithms
Cycle Detection Algorithm ❖ Hash tables
In Real-World Applications,
❖ Networking
❖ Game Development
The algorithm uses two pointers to
traverse the linked list at different
Explanation of this
speeds :
algorithm
➔ Slow pointer (Tortoise) : moves one
step at a time.
➔ Fast pointer (Hare) : moves two steps at
a time.
Steps of the Algorithm:
1→2→3→4→5→6
1 2 3 No match
2 3 5 No match
A simulation of this
algorithm with proper data 3 4 3 No match
4 5 5 Match found
(cycle
detected)
2 3 3 No match
fast = fast->next->next;
if (slow == fast) {
*meetPoint = slow;
return 1;
}
// Function to find the starting node of the cycle
A simulation of this
algorithm with proper data
Complexity