RE: What is the most efficient way of finding a loop i...
Keep tracking the addresses of the nodes visited and each time checking if the address of the newly visited node is already there is the tracking list. If so there is a loop. Continue till this or if the end becomes null.
RE: What is the most efficient way of finding a loop i...
We can have one member variable called visited of boolean type and initialized to false. whenever the node is being visited this variable is set to true. If on traversing any node has this variable set to true initially we conclude that Linked list has loop.
RE: What is the most efficient way of finding a loop i...
just keep a var in the node and assign it as yes on visiting and traverse .......then each time check this field in the node if not visited i.e no then make it yes ............if already yes then u hav a loop