Possible duplicate:How to determine if a linked list has a loop using only two memory locations.
Hi, I was asked in an interview that I can find the loop in the list of links using only two pointers.
I did the following:
1) each time find the center of the list of links
2), repeating this at the end, both pointers will point to the same node, if you do not specify the same node, and find zero, then there is no loop in the list of links.
is there an effective method for this ...?
thanx in advance.
, Floyd, " ". , ( "" ) node , ( "" ) . , "" , "" . , node. - , node .
, , . , . () - node .
1 node , 2 . node , , , . .
, .
- . node . . NULL == second, .
Source: https://habr.com/ru/post/1757611/More articles:Erlang internal function recursion - erlangOpen Source Java EE Presentation Environment - javaIn non-procedural languages, what determines how this should be done? - cPHP: how to scroll through the dynamic number of classes - variablesFree NHibernate or NHibernate for Linq? - c #PHP, MySQL and sleeping connections - phphibernate dao design question - javaHow to use datagrid in wpf? - c #call iphone from my application - iphoneHow to compare Sandcastle conceptual help with Doxygen Pages? - doxygenAll Articles