Reputation: 27
Given a data structure that resembles a linked list with a pointer pointing to next node and another pointer pointing to any random node, I have to print all the unique cycles that the structure has. Here is an example of this data structure:
Unique cycles here are (1,2,1), (2,3,4,5,2), (1,3,5,2,1), (3,4,3) etc. but (1,2,3,4,5,2,1), (1,2,3,4,3) is not a cycle. What should be the algorithm to print all of these unique cycles?
Upvotes: 1
Views: 125