Finding loops/cycles in a linked list

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

Is it really necessary to check whether slow != NULL? Can I simply check for (fast->next != NULL && fast->next->next != NULL) ?

whatever
Автор

Which site or book would you recommend for linked list structure?
i should to study.

nematkosha
Автор

I am having a hard time understanding what would happen if it started looping at node number 3 or 4 basically n>2whereas n is the number of nodes traversed before the first time we encounter a cycle start point. Anyone can help me with that? I tried when n = 3 with 6 nodes total and the first time both pointers intersect at the same location is inside the loop. Basically at node 5. But the problem is the slow pointer didn’t reach the end of the linked list for the first time so we don’t know yet if we are inside a cycle or again since didn’t reach the end from where the cycle loops back which is node 6. Thanks for helping me in advance!

wassimhaimoudi
Автор

Im getting a segmentation fault in the while loop

MonkoGames
Автор

could you put the code from linked lists on a github repository?

catalinvrabiuta