1

Topic: Algorithm of Flojda for search

Esteemed in , in an Internet here but I do not catch up as it works. An example here from the link 60> 50> 40> 30> 20> 10> 40 why such phrase For example here is written: when tortoise comes to 40 hare is at 20 inside the loop.then they both meet at 20. When a turtle on 40, a hare after all on 20 why it is written then they both meet at 20 and Now send tortoise back to first node in the list. Let them both iterate at same speed (one node per step) then I how much understood we should send a turtle on start, when identical values. That is if both the turtle and a hare were on 20 yes, we send a turtle on start. It would be healthy, if someone the code on  or

2

Re: Algorithm of Flojda for search

Hello, e.thrash, you wrote: ET> Esteemed in , in an Internet here but I do not catch up as it works. ET> it would be healthy, if someone the code on  or   Under your link the code on Java?

3

Re: Algorithm of Flojda for search

Hello, GarryIV, you wrote: GIV> Hello, e.thrash, you wrote: ET>> Esteemed in , in an Internet here but I do not catch up as it works. ET>> it would be healthy, if someone the code on  or   GIV> Under your link the code on Java? But me it is not clear as it works. The explanation is not clear, from here and the code is called into question

4

Re: Algorithm of Flojda for search

Hello, e.thrash, you wrote: 60>> 50> 40> 30> 20> 10> 40 ET> why such phrase ET> ET> For example here is written: when tortoise comes to 40 hare is at 20 inside the loop.then they both meet at 20. The hare runs with speed 2, and a turtle with speed 1, thus in a cycle 4 elements. A turtle in a node 40 and to a node 20 it should make two steps, and the hare already in a node 20 but while the turtle does two steps to this node it takes a detour on a cycle. Therefore they meet in a node 20. ET> and ET> ET> Now send tortoise back to first node in the list. Let them both iterate at same speed (one node per step) then This piece simply so not to explain. The proof that it so, you can find in http://www.ozon.ru/context/detail/id/6279127/ Chapter 2.3 a collision Point. The code there a curve. For example public Node FindLoop () {Node tortoise = first; Node hare = first; while (hare.next! = null) {tortoise = tortoise.next; hare = hare.next.next; if (tortoise == hare) {break;}}....}

5

Re: Algorithm of Flojda for search

Hello, StatujaLeha, you wrote: SL> Hello, e.thrash, you wrote: 60>>> 50> 40> 30> 20> 10> 40 ET>> why such phrase ET>> ET>> For example here is written: when tortoise comes to 40 hare is at 20 inside the loop.then they both meet at 20. SL> the Hare runs with speed 2, and a turtle with speed 1, thus in a cycle 4 elements. SL> a turtle in a node 40 and to a node 20 it should make two steps, and the hare already in a node 20 but while the turtle does two steps to this node it takes a detour on a cycle. SL> therefore they meet in a node 20. That is it is meant, what selected 40 it is one object? 60> 50> 40> 30> 20> 10> 40 then why the sequence coming to an end on 40 is given us? After all at us after 40 go 30-20-10 more

6

Re: Algorithm of Flojda for search

7

Re: Algorithm of Flojda for search

Hello, e.thrash, you wrote: ET> that is it is meant, what selected 40 it is one object? 60> 50> 40> 30> 20> 10> 40 ET> then why the sequence coming to an end on 40 is given us? After all at us after 40 go 30-20-10 more Litter, did not understand a question... If to go from a node 60 and to deduce all transited nodes there will be a following broad gull: 60> 50> 40> 30> 20> 10> 40> 30> 20> 10> 40> (30> 20> 10> 40)...

8

Re: Algorithm of Flojda for search

Hello, StatujaLeha, you wrote: SL> Hello, e.thrash, you wrote: ET>> that is it is meant, what selected 40 it is one object? 60> 50> 40> 30> 20> 10> 40 ET>> then why the sequence coming to an end on 40 is given us? After all at us after 40 go 30-20-10 more SL> Litter, did not understand a question... SL> If to go from a node 60 and to deduce all transited nodes there will be a following broad gull: 60>> 50> 40> 30> 20> 10> 40> 30> 20> 10> 40> (30> 20> 10> 40)... I considered it as an array of integer numbers. And it is necessary, as I understand now to consider as the linked list where 40 it is the same object. Truly after all?

9

Re: Algorithm of Flojda for search

Hello, e.thrash, you wrote: ET> I considered it as an array of integer numbers. It not an array. Memberwise there is a separate object. LinkedList object = new LinkedList (); object.insert (10); object.insert (20); object.insert (30); object.insert (40); object.insert (50); object.insert (60); public void insert (int val)//inserts at beginning of list {Node newNode = new Node (val); newNode.next = first; first = newNode;} ET> and it is necessary, as I understand now to consider as the linked list where 40 it is the same object. ET> it is true after all? Yes. There at first there is a list without a cycle, and then its end is shorted on an element on the middle: Node tempObj1 = object.search (40);//creating a loop 60> 50> 40> 30> 20> 10> 40 Node tempObj2 = object.search (10); tempObj2.next = tempObj1;