Programming Anime: Floyd's Algorithm Explained

  Рет қаралды 266,204

JomaClass

JomaClass

Күн бұрын

Join Jomaclass for full-length videos like this: joma.tech/dsa

Пікірлер: 436
@project-pe6ly
@project-pe6ly 4 жыл бұрын
If yall had read the manga yall wouldnt need this explication
@JomaClass
@JomaClass 4 жыл бұрын
Lmaoooo
@The9TKitsune
@The9TKitsune 4 жыл бұрын
I mean Knuth is a great mangaka but he's been on hiatus forever, I can understand everyone's desire to just watch the adapted anime.
@randompotato26
@randompotato26 4 жыл бұрын
TBH I think some details are still missing... the LN was a lot nicer and I would recommend over the manga for sure.
@prodigg9299
@prodigg9299 4 жыл бұрын
Best comment I've read in a while lmaoo
@martinochristanto5216
@martinochristanto5216 4 жыл бұрын
if you read the light novel you could be the senpai teaching him this algorithm
@nintorws
@nintorws 4 жыл бұрын
1.4 million people: Watch a programming anime video just for fun. 36804 of them: I need that power!
@anupchandrahangrai1217
@anupchandrahangrai1217 4 жыл бұрын
Glad to be one of the 95,899.
@mechatronicsprojectsandsim8337
@mechatronicsprojectsandsim8337 4 жыл бұрын
Glad to be one of them
@mrdarip4289
@mrdarip4289 3 жыл бұрын
Glad of be one
@josefaguilar2955
@josefaguilar2955 3 жыл бұрын
Glad
@cp0bo593
@cp0bo593 3 жыл бұрын
Gla
@camuongphan6286
@camuongphan6286 4 жыл бұрын
When a joking video had a good content
@greatbullet7372
@greatbullet7372 4 жыл бұрын
this is legendary
@Rhidayah
@Rhidayah 4 жыл бұрын
Senpai why you so fools 🤣 Just kidding
@alg_strawhat129
@alg_strawhat129 4 жыл бұрын
I wanted to program it myself but I couldn’t, because of my carpal tunnel! Kuso!!!!
@moodman6426
@moodman6426 4 жыл бұрын
unlucky
@Seba-le7mb
@Seba-le7mb 4 жыл бұрын
If you had read the manga, you could be able to do it.
@abeeonaboat1741
@abeeonaboat1741 4 жыл бұрын
Try use voice to text
@abigailyang39
@abigailyang39 4 жыл бұрын
Was just randomly watching funny videos to relax. And now I’m here studying during my break time
@arpitkumar4525
@arpitkumar4525 3 жыл бұрын
Lol same
@juanandrescastillofuenmayo6619
@juanandrescastillofuenmayo6619 2 жыл бұрын
I always start out by watching random stuff for a break and always end up studying because I either feel guilty for not being productive enough or bc it's a topic I'm interested in. Some ppl just can't escape
@doubleliu
@doubleliu Жыл бұрын
Its 4 am trying to sleep
@romyojitpaul2200
@romyojitpaul2200 3 ай бұрын
same bro 😂
@MsJooy
@MsJooy 4 жыл бұрын
yutube overestimated my intelligence once again by recomending this one
@_cytosine
@_cytosine 4 жыл бұрын
Bro, you got this.
@merowareinstance
@merowareinstance 4 жыл бұрын
Lol, you can do this. KZfaq algorithm will provide what it knows you can handle 😄
@NStripleseven
@NStripleseven 3 жыл бұрын
H
@princyangelina_n
@princyangelina_n 4 жыл бұрын
Thank you, Senpai!
@defalt7732
@defalt7732 4 жыл бұрын
Your comment made him to do this vid🤣 Tq
@princyangelina_n
@princyangelina_n 4 жыл бұрын
@@defalt7732 OMG!! I'm caught 😅😅 I can't be guilty of this... 😭😭 But yeah I can't JUST thank him cuz he has put efforts to explain it though he doesn't really have to.
@Majestic469
@Majestic469 4 жыл бұрын
Lol
@kienhuynh1614
@kienhuynh1614 4 жыл бұрын
Some additional info for Method 3 for who was struggling like me: - Notice that in the algorithm, after the hare and the tortoise meet at M in the cycle, we move the hare back to the beginning, then the hare and the tortoise moves 1 step at a time now. - We want them to both meet at the beginning of the cycle now. Why? Because that proves that there are 2 Nodes that have the same number (the node just to the left of the cycle, and the node that close the cycle). Which proves the main problem. Now: - The hare has to take x steps to get from the beginning to reach the cycle. - The tortoise also move x steps in that time. Our hope is that they will meet at the beginning of the cycle after x steps. How do we know that they will meet again after x steps? The hare is stepping from the beginning, the tortoise is stepping inside the cycle, right? To know how, notice the reason why he proves that z = x mod L, and this can be translated to x = kL + z. Basically, while the hare is walking outside in kL + z steps to reach the beginning of the cycle; the tortoise also loops in the cycle k times, goes back to the old meeting point M, then moves z more steps to go to the beginning of the cycle. And they meet. Sorry for being lengthy.
@knightartorias5872
@knightartorias5872 3 жыл бұрын
This is 4 months old but thx man
@FINSuojeluskunta
@FINSuojeluskunta 3 жыл бұрын
Okay I am starting to get it now. Intuitively it means that even if there is a big distance, for the reset pointer to cover, the one stuck in the loop will stay aligned with it and just cycle, and they will still meet at the same point.
@yelena_
@yelena_ 3 жыл бұрын
Thank you. This comment is what got me to finally understand it.
@snooglemunch
@snooglemunch 3 жыл бұрын
I still don't get something. How is the cycle constructed? I understand the logic behind the detection and the modulo math for finding the start of the cycle. But how is the cycle constructed in the first place? Isn't this an array?
@yelena_
@yelena_ 3 жыл бұрын
​@@snooglemunch We treat elements of the initial array as "pointers" to the other elements. So if an element at index 3 has the value of 5, that means it points to the element at index 5. Element at index 5 has a different value so it points to the next index etc. When you draw it as a graph you get what's shown in the video. If two elements of the initial array have the same value, that means they point to the same element/node in the graph. The node that has two elements pointing to it is the one we're looking for. (for example, if the number 3 appears twice in the array that means there are two elements pointing to that element, which translates to two links going into that node on the graph, creating a cycle)
@misterplus306
@misterplus306 4 жыл бұрын
Thank you so much man! That video appeared in my recommendation yesterday and I was so confused... This video is much easier to understand.
@ImposterBraum
@ImposterBraum 4 жыл бұрын
Oh my god thank you soooo much Quality work as usual
@mohammednagdy6661
@mohammednagdy6661 4 жыл бұрын
This is awesome I would love for you to do a series about learning algorithms! I always have huge problem with figuring how to build them!
@TheSchwartzable
@TheSchwartzable 2 жыл бұрын
This was exactly the explanation I was looking for!
@darthbumblebee7310
@darthbumblebee7310 4 жыл бұрын
This is a great explanation. I really liked the way you presented the content. I have been working on a proof that relies on fewer variables and tries to play a little more on intuition. Here it is: --- Let: T be the length of the tail (represented in the video by 'x') L be the length of the loop t be the number of steps the Tortoise has taken after it has entered the loop, starting from the loop's entrance. So at t=0 the Tortoise is at the loop's entrance, at t=1 the Tortoise is one node into the loop, at t=L the Tortoise is back at the loop's entrance, and so on. It follows that the "position" of the Tortoise in the loop is: t mod L. And, the position of the Hare at time t in the loop is: (T + 2t) mod L. The 2t in the above expression comes from the fact that the Hare travels twice as fast as the Tortoise. The T is there because it is the total distance in the loop the Hare has traversed at the time the Tortoise enters the loop. We know T is the distance the Hare traversed in the loop because at the time Tortoise entered the loop, the Tortoise traveled a total of T steps (including the tail), which means that the Hare traveled a total of 2T steps (it is twice as fast) - but the first T of those 2T = T + T steps were spent traversing the tail. So the rest of the T steps the Hare traveled in in the loop. So the meeting of the Tortoise and Hare will occur when: t mod L = (T + 2t) mod L Subtracting t and T from both sides we get: t mod L = -T mod L (These are valid operations since [a mod m = b mod m] if and only if [(a + k) mod m = (b + k) mod m] This tells us that the meet will occur at position: -T mod L. What is position "-T mod L"? It is the position in the loop we get to when we walk T steps backwards in the loop starting at the entrance. So the second part of the algorithm is correct since the pointer starting in the loop will be at the loop's entrance after walking T steps forward from the meeting point. --- Anyway, I hope to see more videos on this channel. Awesome work!
@203bigd
@203bigd 3 жыл бұрын
yo this is dope homie, nice work
@seekndstroy2560
@seekndstroy2560 4 жыл бұрын
big need, thanks joma
@Benw8888
@Benw8888 4 жыл бұрын
Why the algorithm worked wasn't my cause of confusion. What wasn't clear was how you apply this to the problem. It wasn't clear because the most obvious interpretation (which turned out to be right) had a pitfall: what if you immediately get caught in a cycle, like if the array starts with {1,2,...}? (It's a cycle if array indexing starts with 1) And then I realized that array indexing starts with 0 D; which prevents you from being in a cycle at the very start. This forces the graph to turn into the shape you assumed: a line leading into a cycle. ^I think you needed to add this into this video. It was also veeerrry roughly breezed over in the anime edition
@rct3vids99
@rct3vids99 3 жыл бұрын
Thank you for mentioning this! I was wondering about the 0th index and this makes perfect sense
@Timformers
@Timformers 3 жыл бұрын
When a comment blows your mind way more than the video
@L1Q
@L1Q 3 жыл бұрын
I don't see why indexing starting from 0 makes it impossible to have a loop. even if all the numbers are unique, there can still be a place for a number in the array where it points to itself UPD: now I see it, it's impossible to have a number point at index 0 while being on index 0, then if it points elsewhere, the only way a number is pointing on itself would be it having a duplicate elsewhere. you just never find non-duplicate self pointers by going from 0 base
@samuraijosh1595
@samuraijosh1595 6 ай бұрын
@@L1Q no it's totally possible to have a node point to itself. in graph terms, this is called a self-loop and self-loops can be modelled in code. for example: struct Node{ int val; struct Node* next; } Node starting_node; Node.next = &starting_node; this is a self-loop.
@greatbullet7372
@greatbullet7372 4 жыл бұрын
MORE ALGORYTHMS PLEASE! This was astounish entertaining
@dimylameri
@dimylameri 4 жыл бұрын
Can you imagine another application for this algorithm? Because it seems pretty specific to this problem and these constraints
@JomaClass
@JomaClass 4 жыл бұрын
Not gonna lie, it’s pretty useless in real world applications.
@kratosgodofwar777
@kratosgodofwar777 4 жыл бұрын
@@JomaClass bruh
@Fenvirr
@Fenvirr 4 жыл бұрын
It's literally named Floyd's cycle-finding algorithm, so I'd assume that it only serves that niche purpose. I'd assume you can use it to prevent yourself from revisiting a node when traversing a list as a result of cycles, but I'd also assume there's better methods of doing such.
@TheNewton
@TheNewton 4 жыл бұрын
Embedded hardware, SKU handling
@tdgray978
@tdgray978 4 жыл бұрын
Well it’s already kind of a case of an algorithm that does one thing is being used for another problem. Floyd’s algorithm detects cycles, but the original problem was about finding duplicates in an array. It’s by reformatting the problem so that Floyd’s algorithm could be used that they’re able to solve it under the constraints.
@siddhantdeshmukh7120
@siddhantdeshmukh7120 4 жыл бұрын
Damn!! Now I may want to check out your other videos
@k2x2x2s
@k2x2x2s 2 жыл бұрын
oh Joma your video is so awsome T^T
@user-vl7nk5gj6m
@user-vl7nk5gj6m Жыл бұрын
Great video. This is my favorite anime.
@AleksandarDragon
@AleksandarDragon 4 жыл бұрын
Stumbled upon the channel because of anime video, like it so much so that look for this video for the explanation :D subscribed for the normal educational content
@dark_knight987
@dark_knight987 11 ай бұрын
Belive i was just left wondering watching the anime video ,keep up these algorithm videos ❤
@sparkx611
@sparkx611 4 жыл бұрын
appreciate for this detailed explained video!
@ClaudioParraGonzalez
@ClaudioParraGonzalez 2 жыл бұрын
Beautifully explained. Thanks.
@tseren
@tseren 4 жыл бұрын
I watched a few of these and didn't grasp it until I watched your mathematical explanation. Thanks.
@xx_Ashura_xx
@xx_Ashura_xx 4 жыл бұрын
Hey man love your videos! Someone with programming, tech, and comedy lol
@TrueZenquiorra
@TrueZenquiorra 4 жыл бұрын
Joma, totally loving this type of videos. I would pay to learn like this xD
@edwingarcia5043
@edwingarcia5043 4 жыл бұрын
pay 900 dollars ?
@hunghung-mu6se
@hunghung-mu6se 2 жыл бұрын
thanks you for Floyd's Algorithm Explained
@hilmidwiputranto6944
@hilmidwiputranto6944 4 жыл бұрын
1:17 he even gave a spoiler warning, such a cultured man
@RomanTokarenko
@RomanTokarenko Жыл бұрын
Nice proof, thanks a lot, man!
@jhonconnor8440
@jhonconnor8440 4 жыл бұрын
This video is pure gold
@pinoyXasian
@pinoyXasian 4 жыл бұрын
bruh, this is helping me study and is making it the first leetcode medium I've solved. Whoever said anime wasn't useful?
@Philgob
@Philgob 9 ай бұрын
beautiful explanation
@callmechocolateboy
@callmechocolateboy 4 жыл бұрын
Dude new channel 😎👍👍👍👍👍
@abhilashpatel3036
@abhilashpatel3036 4 жыл бұрын
I came here cause the hashmap solution failed and my whole world went upside down 😥
@kevinstefan98
@kevinstefan98 4 жыл бұрын
I don't see how this solves the original problem of finding the duplicate number, though. The array could easily have extra cycles that are unconnected to the duplicate entry. For instance [1, 0, 2, 2]. 0 and 1 form a cycle, but the duplicate entry is not included in that cycle.
@yogiturtleseraph8208
@yogiturtleseraph8208 4 жыл бұрын
Yeah, if the graph is not fully connected we might have a problem [probably the most frequent case]. But I think we can handwave that for the sake of comedy. And because the rest of the explanation is pretty cool.
@_Ytreza_
@_Ytreza_ 4 жыл бұрын
Numbers in the array are from 1 to n, it can't contain 0. I think this ensures that the duplicate is always in the cycle.
@muchammadwahyu2993
@muchammadwahyu2993 4 жыл бұрын
Please make more anime videos. It makes programming so funny and enjoy to learnt 😁
@jheandaza7334
@jheandaza7334 4 жыл бұрын
Excelente! I admire you!
@MehtaAvant
@MehtaAvant 2 жыл бұрын
For the input set [2,1,4,3,4] The 2 and the 1 point to eachother, and the 4 and 3 also point to eachother. How does the algorithm deal with the case when the duplicate number is entirely outside of the loop that starts with index 0 ?
@lamrin9178
@lamrin9178 4 жыл бұрын
RIP , was searching for floyd warshall watched the whole thing :))
@CodeF416
@CodeF416 4 жыл бұрын
Cool joma has a programming channel thank you joma
@kr13031
@kr13031 Жыл бұрын
Thanks sir, this helped me last night to sleep after 2 days of no sleep. After I checked I fell asleep at 11.47 .
@Nemo-ir9zl
@Nemo-ir9zl 2 жыл бұрын
thank u so muchhhh
@John_does
@John_does 4 жыл бұрын
Question, how you avoid lenght 1 loops in the question in the original video? like if 1 is the first element?
@naasifn
@naasifn 4 жыл бұрын
So, once we get X mod L means Z we have the starting point of the circle and decreasing by 1 we have the duplicate number, right? If I am right, then why don't we say the meeting point is the duplicate number? In the problem they didn't want positions of duplicate numbers. The just wanted the value which was written twice. Ain't that right? or we just need to make sure that duplicate numbers exist and we need to check arr[x-1]==arr[x+z]?
@corozco
@corozco 4 жыл бұрын
Coolness Intensified
@helboy1111
@helboy1111 4 жыл бұрын
Am I correct in my understanding that after the hare moves 1 by 1 (from the meeting point described at 8:08 ), the hare might still loop any number of times before getting to the start of the loop at the same time as the turtoise? Since the turtoise moves x, which is later written as l + l + ... + l + a, and a = z that would mean that the hare still moves any amount of loops equal to the distance the turtoise has to travel as l distance as part of x. Great video! I already put aside the Wikipedia page on it for later, but this works even better ;)
@RioChandra
@RioChandra 4 жыл бұрын
i still don't get it,. maybe after code by my self or read some explaination from other reference,. my brain too hard to understand..
@forgottenmohawks8734
@forgottenmohawks8734 4 жыл бұрын
I still don’t get how we use it for the problem in question though 😅
@henkkk450
@henkkk450 3 жыл бұрын
Me too mate
@funnygeeks8126
@funnygeeks8126 4 жыл бұрын
You should have explained how we know we will start on the line part of the graph: 0 indexed arrays, but numbers start at 1.
@EricDongh2p
@EricDongh2p 4 жыл бұрын
Yeah I was also confused on that part.
@couchcamoteChannel
@couchcamoteChannel 4 жыл бұрын
I found this algorithm way before for finding out if a Linked List has a cycle. So I was surprised when I saw this same algo used on finding a duplicate number in an array.
@zAlbee2
@zAlbee2 4 жыл бұрын
I was surprised as well. ~Turns out it doesn't work. Try [1,2,2] or [2,1,3,3]. See my comment for why.~ EDIT: I WAS WRONG! IT WORKS AFTER ALL 😮
@L1Q
@L1Q 3 жыл бұрын
@@zAlbee2 please explain why it works on [2,1,3,3] my brain tells me it would be stuck on number 1 (index 1) and think it's the solution. UPD: ok so the reason why [2,1,3,3] would still work is because we start from index 0 and jump directly to index 2, which contains value 3. this fixes both turtle and hare on index 3. holy shit this came to me. if a number is pointing to its own position it's basically out of the graph completely unless it's duplicate! genius! thank you Albert for giving a push in the right direction now I see the solution clearly AND understand why it works
@blindarion4127
@blindarion4127 4 жыл бұрын
What if the induced graph has multiple connected components (a.e. [2,3,1,5,6,5,5])? Starting in a wrong connected component means that you won't get a correct result, right? Am I missing something? Is this input illegal?
@Jaojao_puzzlesolver
@Jaojao_puzzlesolver 3 жыл бұрын
Can't wait for the season 2
@pablojavier7965
@pablojavier7965 Жыл бұрын
6:03 Why do you use a set and not another array/list? You’re gonna fill n elements in the worst case scenario in both so is there an advantage in using a set?
@richard1762
@richard1762 4 жыл бұрын
Just use set negative to the value index and use the abs of the value while you scan the array to check whether the value index is negative. If its negative it means it has duplication.
@Naton
@Naton 4 жыл бұрын
Err what are you talking about?
@jasonpamintuan7096
@jasonpamintuan7096 4 жыл бұрын
Yeah I saw that solution, but in this case you can’t modify the array
@Arjunsiva
@Arjunsiva 4 жыл бұрын
Verithanam da Mamey!
@sanjayd9675
@sanjayd9675 3 жыл бұрын
yes macha
@z41n
@z41n 4 жыл бұрын
Hey Joma, what tablet do you use to do these types of explanations? Really need a simple and clean one. Thanks
@huuphuocle2633
@huuphuocle2633 4 жыл бұрын
Correct me if I'm wrong. But if you start a a node in the circle, the two pointers will meet at the starting node, them you will return value of that node no matter where the duplicate is. Edit: i figure it out.
@hellosagar
@hellosagar 3 жыл бұрын
Thanks
@Rohith_E
@Rohith_E 4 жыл бұрын
@18:36 L-Y is not the remainder of Y mod L after all the other Ls are gone. Rather we know that there is at least one complete loop by hare before it meets tortoise, so we rewrite (k*L - Y) mod L as (L - Y) mod L (since k cannot be zero) which is Z mod L which equals Z.
@L1Q
@L1Q 3 жыл бұрын
what happens if any number is pointing on itself? UPD: my mind just ascended to solution. if any number points at itself (value = 0 based index), we will never find it by going from index 0 and forward through the graph. it is only possible to get on the index the value points to by having a duplicate value pointing to same index.
@Kris_misra
@Kris_misra 2 жыл бұрын
Hey can we also use it in counting how many times that particular alphabet is being repeated I a string(array of string )?
@artemy1046
@artemy1046 2 жыл бұрын
That is so cool! What program are you using for this video?
@RainerRitsch
@RainerRitsch 4 жыл бұрын
Can somebody please explain how to find out the length of x and thus the start of the loop? Everything afterwards is clear to me
@siobhanahbois
@siobhanahbois 4 жыл бұрын
An explanation about finding the entry point part. First assume when fast and slow meet, slow has moved a steps, and fast has moved 2a steps. They meet in the circle, so the difference a must be a multiple of the length of the circle. Next assume the distance between beginning to the entry point is x, then we know that the slow has traveled in the circle for a-x steps. How do we find the entry point? Just let slow move for another x steps, then slow will have moved a steps in the circle, which is a multiple of length of the circle. So we start another pointer at the beginning and let slow move with it. Remember x is the distance between beginning to the entry point, after x steps, both pointer will meet at the entry of circle.
@TraceguyRune
@TraceguyRune 4 жыл бұрын
But what is the line vs the circle?
@NivedhaOrton
@NivedhaOrton 4 жыл бұрын
Make more videos about algorithms or data structures....
@tofo7151
@tofo7151 4 жыл бұрын
where do i start to learn most of this? any books you can recommend?
@emmaodonnell8275
@emmaodonnell8275 4 жыл бұрын
Can you get a false positive on a cycle here? If you're using 1 based indexing and you start the hare and turtle in position 1 then you immediately get stuck in a loop right?
@Iknowrealtv
@Iknowrealtv 4 жыл бұрын
I'm not even a programmer but I need to watch this. Since the Anime was just to good.
@merowareinstance
@merowareinstance 4 жыл бұрын
iKnowRealTV lol, best answer. How did you get into programming? Umm, I watched anime. Lolz
@Iknowrealtv
@Iknowrealtv 4 жыл бұрын
@@merowareinstance facts
@danielmc5693
@danielmc5693 4 жыл бұрын
This might be a dumb question, but how do you know when to end x and start the loop. If the hare went twice as fast as the tortoise, wouldn't if go the beginning of the array?
@RainerRitsch
@RainerRitsch 4 жыл бұрын
my question exactly
@randomcarbonaccumulation6478
@randomcarbonaccumulation6478 4 жыл бұрын
From my understanding of the problem, the tortoise and the hare don't go through the array in order (array[0]-->array[1]-->array[2]). Instead, they start at index 0, look up the number in the array at this index, and go there. So if array[0] was 6, the tortoise would go to array[6], and if array[6] was 3, it would go to array[3] in the next step. (The hare does the same, just twice as fast). Think of the value in the array at a certain index as a pointer that tells tortoise and hare where to go next. Because there is a duplicate value in the array, two of these pointers point to the same index. Once the tortoise or hare get to the second occurrence of this value, they go back to a value they have already visited, and if they follow that path, they will eventually get to the second occurrence again and again and again. We don't tell the tortoise and hare where to loop back, they automatically do once they get to the duplicate number. Floyd's algorithm can detect where this loop starts. At least that's what I understood. I hope I could help, tell me if I got something wrong
@user-vf3kk8vg4n
@user-vf3kk8vg4n 4 жыл бұрын
"Senpai you are so cool!!"
@k0alk0
@k0alk0 4 жыл бұрын
What will happen if, let's say, there is a value of 1 in an element with the index of 1?
@nikatamliani3790
@nikatamliani3790 4 жыл бұрын
array must be zero indexed, so at firs you must reach some index with value 1 to reach index 1, this means the duplicate number is 1, otherwise you can't reach index 1. it's not special case.
@B1SQ1T
@B1SQ1T 3 жыл бұрын
I'm a bit confused by the whole traverse then loop part. Is X the size of the whole array? Like say I have [1,2,3,4,4] is X gonna be 5?
@imacds
@imacds 4 жыл бұрын
Use a Tardis instead of a Tortoise, so that P = NP.
@ogeretla9332
@ogeretla9332 4 жыл бұрын
hey man, nice videos. (im not good at algorithms and stuff)Just wondering, would you be able to determine (from the limitation in speed) how long can the variable N get? Cuz then, by seeing the time in which the program has to determine the duplicate, you'd know that even with an algorithm like Floyd, if you have N a certain size it would exceed the time.. So you could just estimate the max length of N and just make a frequency array... I m not sure if this would really exceed the space no matter what, but time should be fine.... right? probably its really stupid question, the main thing is that a frequency array wouldnt work cuz the max size of N is not specified, and im really trying to see if theres a way to make it work.
@LUITEN1
@LUITEN1 4 жыл бұрын
Thank you very much!! I just started studying C, like, 4 hours ago, and got pretty happy to kinda understand the anime video an fully understand this one! Subscribed!
@andreicalcan4889
@andreicalcan4889 4 жыл бұрын
How do you get from an array to a graph using pointers?
@karansharma8951
@karansharma8951 3 жыл бұрын
he is converting array to linked list
@SauravKumar-kj1uu
@SauravKumar-kj1uu 4 жыл бұрын
U can get in a way like... There is a circular race track... Everyone starts with different speed.... They will meet again at there LCM of speed... Trying in linked list loop
@bansalashu1613
@bansalashu1613 4 жыл бұрын
no you cant like that because you have to first know where the circular track starts.
@rohandevaki4349
@rohandevaki4349 2 жыл бұрын
great explaination, you could have explained how to write code for it too,
@thanhhuynhtan9724
@thanhhuynhtan9724 4 жыл бұрын
hello senpai, ware ware wa Pain.. kami da, and my question is what is the name of program you use to write things out on screen. Thank you so much
@MrExample00
@MrExample00 4 жыл бұрын
Anyone know what software he uses for the explanation (blackboard)
@del6553
@del6553 2 ай бұрын
The proof is under the assumption that y > 0 if y = 0, then xmodL = 0, meaning x is a multiple of L, which implies the meeting point would be at the start of cycle, and the tortoise would still meet the new pointer at the start of cycle, so in the end everything still works out
@jasonhsieh8644
@jasonhsieh8644 8 ай бұрын
the best video for explaining why the distance magic would work! X mod L = Z is amaing!
@nirajraut9408
@nirajraut9408 3 жыл бұрын
Can someone tell me which software he is using to write and proof that algorithm?
@vinaysinghjadon1959
@vinaysinghjadon1959 4 жыл бұрын
Explaining programming with anime its the best thing i have seen after ben10
@Eireannade
@Eireannade 4 жыл бұрын
I almost commented on the equation but then I realised you were correct it's just the way you described it confused me. Anyways, well done, I really enjoy reading on mathematical algorithms and this one was really nice, I enjoyed watching the vid. I really enjoy the mathematical aspect of programming it's quite fascinating how mathematics is everywhere in our lives. Proves how idiotic it is to think mathematics is useless after school. Well, loved the vid.
@carmineg
@carmineg 2 жыл бұрын
What program/app are you using for the drawing here? It's really nice and clean!
@nicorobin7666
@nicorobin7666 4 жыл бұрын
Hey Joma San tell me, How to start practicing these algorithms, and what is the best resources / websites to do so?
@panchociarer
@panchociarer 4 жыл бұрын
Introduction to algorithms by clrs is a good resource
@Ureallydontknow
@Ureallydontknow 3 жыл бұрын
But you didn't show the function calls or the instruction set with pointers. I already know modular arithmetic and coding but I'm not sure what this video can do for me. Show the code.
@cp0bo593
@cp0bo593 3 жыл бұрын
I tested, it works but I didn't understand just why it does work. Thing I didn't understand is neither tortoise nor hare is following a regular sequence. For example in that anime video, code is used for 3,1,3,4,2 array if I am not wrong. In that example, tortoise goes from first element of array to fourth element of array then fifth element of array then thirth because the code is tortoise=nums[tortoise] and hare goes from first to fifth to fourth to thirth because the code is hare=nums[nums[hare]]. Tortoise doesn't go like 1 forward 1 forward 1 forward. It goes 3 forward 1 forward 2 back. I understood the math in these video and why x mod L = z but what exactly prooves x mod L = z and why? Can anyone help?
@Seanabo
@Seanabo 3 жыл бұрын
I get that we've found a cycle but I still don't get how that cycle is used to find the duplicate number in given set.
@NStripleseven
@NStripleseven 3 жыл бұрын
Not sure I understand what Floyd's algorithm does. What is the thing the pointers are on? What does that represent?
@not_vinkami
@not_vinkami 4 жыл бұрын
so why don't we use nums.count(i) for i in nums (Not in correct syntax)? We can just catch nums.count(i) > 1 and output i
@marcocheng2736
@marcocheng2736 4 жыл бұрын
You thought this video is supposed to be meme, but it was ME FLOYD!
@SteveReals
@SteveReals 4 жыл бұрын
In your anime, you find a duplicate number using the value at a given index as the next index. Is there a generic solution for the special case where a[0] := 0?
@JomaClass
@JomaClass 4 жыл бұрын
Oh that won’t happen because numbers are from 1 to n in the question. The algorithm doesn’t work if one of the value can be 0
@BetaNegative
@BetaNegative Жыл бұрын
At 14:35 "you can just think about it" is, well...unenlightening
@user-dp9yn7zf4l
@user-dp9yn7zf4l 3 жыл бұрын
senpai,you are so smart
@lostmeme9862
@lostmeme9862 Жыл бұрын
I tried it and it did not work. Then I realized the ints start at 1 not 0, and it worked.
@vm20709
@vm20709 3 жыл бұрын
The confusion for me was that the array isn't an arbitrary array of numbers. It's actually a linked list that can potentially go into a infinite cycle.
Check for Palindrome | Data Structures & Algorithms
12:52
JomaClass
Рет қаралды 10 М.
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 38 МЛН
THEY WANTED TO TAKE ALL HIS GOODIES 🍫🥤🍟😂
00:17
OKUNJATA
Рет қаралды 13 МЛН
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
How I Failed the Google Coding Interview (and lessons I learned)
14:24
The Art of Linear Programming
18:56
Tom S
Рет қаралды 632 М.
Poison Wine Problem: Understanding Bits
7:49
JomaClass
Рет қаралды 20 М.
The Absolute Best Intro to Monads For Software Engineers
15:12
Studying With Alex
Рет қаралды 602 М.
What are Variables? A Python Example
14:47
JomaClass
Рет қаралды 18 М.
Why Floyd's Cycle Detection algorithm works?
19:30
Dinesh Varyani
Рет қаралды 19 М.
How Dijkstra's Algorithm Works
8:31
Spanning Tree
Рет қаралды 1,3 МЛН
Big-O Notation - For Coding Interviews
20:38
NeetCode
Рет қаралды 420 М.
NERF WAR HEAVY: Drone Battle!
00:30
MacDannyGun
Рет қаралды 38 МЛН