2 votes 2 votes Write $O(n)$ time algorithm to find any cycles in a graph. Print NONE otherwise Algorithms algorithms graph-theory + – rahul sharma 5 asked Apr 5, 2018 • recategorized Jul 6, 2022 by Lakshman Bhaiya rahul sharma 5 820 views answer comment Share Follow See all 5 Comments See all 5 5 Comments reply Show 2 previous comments Tesla! commented Apr 5, 2018 reply Follow Share Graph is directed or not ? 0 votes 0 votes rahul sharma 5 commented Apr 6, 2018 reply Follow Share Can we have general for both directed and undirected? 0 votes 0 votes smsubham commented Apr 10, 2018 reply Follow Share For LL: https://www.geeksforgeeks.org/detect-loop-in-a-linked-list/ For Graph: Floyd’s Cycle-Finding Algorithm: This is the fastest method. Traverse linked list using two pointers. Move one pointer by one and other pointer by two. If these pointers meet at some node then there is a loop. If pointers do not meet then linked list doesn’t have loop. Ref: geeksforgeeks 0 votes 0 votes Please log in or register to add a comment.