Why Floyd's Cycle Detection Algorithm Works | Cycle detection in Linked List

  Рет қаралды 36,269

Knowledge Center

Knowledge Center

Күн бұрын

Пікірлер: 74
@itsmeac101
@itsmeac101 2 жыл бұрын
even after two years. this remains the best proof i could find. thank you!
@KnowledgeCenter
@KnowledgeCenter 2 жыл бұрын
Glad to hear.
@theawless
@theawless 3 жыл бұрын
Amazing! This is the most complete proof of the algorithm I've seen. I was tired looking at wikipedia and stack-overflow. Some people made the assumption that hare will make only one loop before reaching the meeting point, but no one explained why. It seems that's the wrong logic. In your proof you mentioned that hare and tortoise can both make some number of loops.
@KnowledgeCenter
@KnowledgeCenter 3 жыл бұрын
Thanks. Glad it helped.
@AndreiSokolov-k7j
@AndreiSokolov-k7j 8 ай бұрын
no it's wrong explanation, e.g why he thinks, that length of the loop it's 8? it's 7. and also tortoise can not do ANY number of loops
@kaifk5889
@kaifk5889 4 жыл бұрын
Sir the way you explained the problem was really amazing. Hoping to see more algorithm videos soon.
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Thanks. Check other playlists.
@Vibedecoded
@Vibedecoded Жыл бұрын
Best explanation hands down !
@abhijitdutta8458
@abhijitdutta8458 26 күн бұрын
Great Explanation. Thank you!
@svalyavasvalyava9867
@svalyavasvalyava9867 3 жыл бұрын
I'm so grateful for this explanation. Thanks a ton 😌
@KnowledgeCenter
@KnowledgeCenter 3 жыл бұрын
Happy to help!
@prabhupuredla8280
@prabhupuredla8280 4 жыл бұрын
the explanation is clean and precise. Thanks for the video
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Thanks.
@rohith8269
@rohith8269 4 ай бұрын
Such a great explanation!
@takitazwarparthib3555
@takitazwarparthib3555 4 жыл бұрын
GREAT EXPLANATION SIR! HELPED ALOT.. SPECIALLY THAT LAST EXPLANATION WAS EXCELLENT
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Thanks.
@zaabimahdi
@zaabimahdi 3 жыл бұрын
this is the best ever explanation !
@KnowledgeCenter
@KnowledgeCenter 3 жыл бұрын
Thanks.
@boladjivinou7295
@boladjivinou7295 2 жыл бұрын
Thanks a lot, this is the most logic explanation
@KnowledgeCenter
@KnowledgeCenter 2 жыл бұрын
Glad you think so!
@rohanprak
@rohanprak 4 жыл бұрын
thanks a lot for such a great explanation, this could not have been better.
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Thanks. Glad you learnt something useful from the video.
@KS0607
@KS0607 Жыл бұрын
extremely lucid great thanks
@KnowledgeCenter
@KnowledgeCenter Жыл бұрын
Thanks.
@Amygdala57-c8c
@Amygdala57-c8c 9 ай бұрын
M = (s*C2-f*C1)*N/(f-s) - (f-s)*K So, if the slow pointer moves "s" step at a time, the first pointer will move (f-s) step to meer the beginning of the loop. Here, s=1, f=2. So slow moves 1 step and fast moves (f-s)=1 step at a time. Got it.
@DeepakKumar-wh7bv
@DeepakKumar-wh7bv 5 жыл бұрын
Thank You Very Much Sir !. This video solved my doubt. Please Keep uploading videos on problems with mathematical base. Please make a "video series" on Time Complexity Finding (without using master theorem ) . I have subscribed your channel and waiting for another videos.
@KnowledgeCenter
@KnowledgeCenter 5 жыл бұрын
Thanks Deepak. That's really encouraging. Will be creating more series on algorithms and problem solving soon.
@tsaoliam5422
@tsaoliam5422 Жыл бұрын
Best explanation
@kartikeydixit3743
@kartikeydixit3743 3 жыл бұрын
Very clear explanation . Thankyou so much
@KnowledgeCenter
@KnowledgeCenter 3 жыл бұрын
Glad it was helpful!
@trivialnonsense
@trivialnonsense Жыл бұрын
Excellent. Thank you
@KnowledgeCenter
@KnowledgeCenter Жыл бұрын
Glad it was helpful!
@diptiprakashsinha
@diptiprakashsinha 3 жыл бұрын
Nice explanation
@KnowledgeCenter
@KnowledgeCenter 3 жыл бұрын
Thanks.
@crisag.2698
@crisag.2698 4 жыл бұрын
What I'm confused about is how the fast pointer could make more than 2 cycles around the loop before it meets the slow pointer. Intuitively, in my minds eye I see the fast pointer moving at 2x the speed, so I would think that the overlap would happen somewhere before the fast pointer begins its third cycle.
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
That can depend on the size of the loop. Lets say There are 100 nodes before cycle, and 1st node of cycle is 101th node. The cycle has lets say 10 nodes. So, after time step 50, slow pointer will be at 50th node, fast pointer will be at 100th node and touching the beginning of Cycle. after 5 more time steps, fast pointer will complete 1 round of cycle, since it has just 10 nodes. Slow pointer will reach 55th node, still far from beginning of cycle. After next 5 time steps, fast pointer will complete another round of cycle, slow pointer will be at 60th node and still far from beginning of cycyle. At time step 101, slow pointer will enter Cycle. By that time fast pointer has already completed 10 rounds of cycle. Now, chase will start between rabbit and tortoise.
@mehrabhasan5773
@mehrabhasan5773 3 жыл бұрын
Great explanation. Thanks a lot.
@KnowledgeCenter
@KnowledgeCenter 3 жыл бұрын
Welcome
@umangmalhotra1222
@umangmalhotra1222 Жыл бұрын
very good explantion.
@Its_Sunny-qe8ve
@Its_Sunny-qe8ve Жыл бұрын
In what case, the slow pointer will complete at least 1 loop because I am getting that in every case , fast pointer will catch slow one before the loop 1 complete. Can anyone provide example in which slow pointer completing at least 1 complete circle of loop
@sunnykumarsingh7039
@sunnykumarsingh7039 8 ай бұрын
Excatly bro!
@prakulcool
@prakulcool 4 жыл бұрын
Well explained. Thank You Sir!
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Thanks.
@manishvohra1953
@manishvohra1953 4 жыл бұрын
Awesome explanation
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Thanks.
@happyhome422
@happyhome422 4 жыл бұрын
Thank you for nice explanation. 🙏upload more videos
@urmanratneshwar
@urmanratneshwar 3 жыл бұрын
thanks a lot for this explaination...
@KnowledgeCenter
@KnowledgeCenter 3 жыл бұрын
Glad it was helpful!
@joeys8832
@joeys8832 Жыл бұрын
Thank you!
@KnowledgeCenter
@KnowledgeCenter Жыл бұрын
Welcome!
@shivam7304
@shivam7304 2 жыл бұрын
bro the explanation was on point but you need a media player to increase your speed though...
@KnowledgeCenter
@KnowledgeCenter 2 жыл бұрын
Right. Speed has increased in later videos.
@paragroy5359
@paragroy5359 4 жыл бұрын
Nice explanation sir......
@SpaceExplorer
@SpaceExplorer 2 жыл бұрын
thank you sir
@KnowledgeCenter
@KnowledgeCenter 2 жыл бұрын
Welcome.
@MyJapaneseLife
@MyJapaneseLife 4 жыл бұрын
Hey @KnowledgeCenter, Should the symbol "=>" you draw in the video be ""? Also your video are a bit slow. I have to play it at 1.25x to save my time... Anyway thanks for the video, helped me understand the algorithm. Edit: This video deserves much more views and thumb ups because it explains the algorithm in mathematical way unlike many other videos.
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Thanks. My earlier videos were a bit slower as I was drawing using touch pad.. Newer videos are a bit faster. For older ones recommended speed is 1.25x at least.
@chandrasharma1951
@chandrasharma1951 4 жыл бұрын
Nice explanation. However I was searching for floyd cycle algorithm (behind the scene maths). And please speed up, I played it at 3x so that I don't get bored.
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
In recent videos I have speeded up a bit.
@chandrasharma1951
@chandrasharma1951 4 жыл бұрын
​@@KnowledgeCenter Thank you. BTW I worked up on the maths, two pointers starting at position a and b inside loop with speed x and y respectively to meet at point t have to satisfy equation a + xt ≡ b + yt mod N, where N is loop length, but it shows that they will not meet if (x-y) is not co-prime with N. Please do add the explanation for this and whether I am wrong on this or right. Thanks in advance.
@alifrahman7099
@alifrahman7099 4 ай бұрын
Nice proof. ❤❤
@tongl7380
@tongl7380 4 жыл бұрын
nice video! helps me a lot, thank you
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Great.
@tareqmahmud7760
@tareqmahmud7760 2 жыл бұрын
nice, thanks
@KnowledgeCenter
@KnowledgeCenter 2 жыл бұрын
Welcome 😊
@bagasadifirdaus9278
@bagasadifirdaus9278 3 жыл бұрын
Sir can you tell me why the slow pointer is guaranteed not to go over the full loop before meeting the fast pointer?
@udbhavvikramsingh3449
@udbhavvikramsingh3449 3 жыл бұрын
same Q !!!! did you find the answer bro. if yes then share with us.
@abhishekroy1028
@abhishekroy1028 2 жыл бұрын
It is not guaranteed. If you watch the video, he mentioned 'in most cases' it'll be one.
@payalsagar1808
@payalsagar1808 4 жыл бұрын
wow short and crisp!🙆
@KnowledgeCenter
@KnowledgeCenter 4 жыл бұрын
Thank you 😋
@kamaninikhil71
@kamaninikhil71 3 жыл бұрын
I didnt get why we ignored numbers of loops as constant
@nectarofcoding6233
@nectarofcoding6233 3 жыл бұрын
mujhe acha nhi lga
@lambar0
@lambar0 Жыл бұрын
Nice explanation
@KnowledgeCenter
@KnowledgeCenter Жыл бұрын
Thanks for liking
Why Floyd's Cycle Detection algorithm works?
19:30
Dinesh Varyani
Рет қаралды 21 М.
Молодой боец приземлил легенду!
01:02
МИНУС БАЛЛ
Рет қаралды 2,1 МЛН
How to Fight a Gross Man 😡
00:19
Alan Chikin Chow
Рет қаралды 17 МЛН
If people acted like cats 🙀😹 LeoNata family #shorts
00:22
LeoNata Family
Рет қаралды 23 МЛН
S1 Percentages
12:39
Mr Christie
Рет қаралды 148
L14. Detect a loop or cycle in LinkedList | With proof and Intuition
20:26
Programming Anime: Floyd's Algorithm Explained
19:44
JomaClass
Рет қаралды 269 М.
Remove Loop from Linked List | Floyd's Algorithm
9:11
Knowledge Center
Рет қаралды 12 М.
Why Floyd's cycle detection algorithm works? Detecting loop in a linked list.
24:11
Vivekanand Khyade - Algorithm Every Day
Рет қаралды 114 М.
Detect a Cycle in Linked List | Amazon | Samsung | Microsoft
11:36
take U forward
Рет қаралды 131 М.
Молодой боец приземлил легенду!
01:02
МИНУС БАЛЛ
Рет қаралды 2,1 МЛН