Post

trish
trish@TrisH0x2A·
Floyd's cycle detection algorithm finds a loop in a linked list using just two pointers and O(1) extra space one pointer moves one node at a time while the other moves two if a cycle exists they are guaranteed to meet after they meet reset one pointer to the head and move both one step at a time the node where they meet again is the exact start of the cycle one elegant proof from modular arithmetic powers one of the most famous linked list algorithms ever written
trish tweet media
English
9
36
446
122.5K
Taki
Taki@TakiSplatoon·
@Entity3Self @TrisH0x2A I actually first heard of this algorithm because it's used in Google's "Guava" library: #L267-L307" target="_blank" rel="nofollow noopener">github.com/google/guava/b…
English
0
0
4
319
BIGO LIVE
BIGO LIVE@BIGOLIVEapp·
Up late and bored? Tap into live conversations.
English
34
30
455
6.3M
Paylaş