• 2 weeks ago
Transcript
00:00What are we going to do? We are going to play a little math.
00:02Before, I made a diagram of my situation.
00:05We have considered a link list which is connected with a node.
00:11Can I say this distance?
00:14I have called x here.
00:17Can I say that the loop of the link list covers total distance d?
00:25I have considered such a situation.
00:27Now for the first time, I have detected my cycle.
00:30What was the first step of my detection cycle?
00:34What did I do in the first step?
00:35I was running slow by 1 and fast by 2.
00:38So I will get both going and where?
00:41I believe that the meeting point of both will be here.
00:45Here is my slow and here is my fast.
00:49I will say that the distance of meeting point is so much.
00:56This distance is my distance equal to y.
01:00This distance is my distance equal to y.
01:01This is my x distance.
01:02This is my y distance.
01:03What can I say?
01:04By default, this distance is equal to d minus y.
01:07Total distance is d.
01:08So I have changed from y.
01:11So I have called this distance.
01:13This distance is d minus y.
01:15This is important.
01:16In mathematical terms, I have seen what distance is in the diagram.
01:20It is logical.
01:22I have assumed that I will call this x.
01:23I will call this y.
01:25I will call this distance.
01:26I will call this distance from the distance.
01:27I will call it d minus y.
01:29And the total inside is equal to d.
01:31Now, when I have left my slow and here,
01:36I will call it from the initial point.
01:39Now, I will call it fast and slow.
01:43Now, if I think that this will come again,
01:47because I know that if I leave slow and fast
01:51I will call it from a cycle link list,
01:53then I will find them somewhere.
01:55Now, I have to find out where they will find them
01:57or that I will mathematically prove
01:59that they will find them at this point.
02:01If we find slow and fast,
02:04then what is the mathematical condition here?
02:07How will slow cover the distance?
02:10Slow has covered the distance.
02:12That is equal to x
02:13plus a into d
02:15plus y.
02:16That means slow,
02:18some x-distance.
02:20After that,
02:21I will find a little bit of a loop.
02:23How many?
02:24It will cover a-to-d distance.
02:27Plus,
02:28it has covered y-distance
02:29because it had to reach here.
02:32It meant it had to reach any meeting point.
02:34I have written a lot of generic terms
02:35and I have also found a meeting point.
02:38So, I have considered a meeting point
02:39as a general meeting point.
02:39We are considering the slow distance
02:42before it came here.
02:43Then he added a number of chakras and then he added a number of chakras and then he added a
02:48y distance.
02:50How much distance did he travel fast?
02:52That's how much distance.
02:54How much distance did he travel fast before getting slow?
02:59The pointer was the first time.
03:02He also covered x distance.
03:05Fast was the first time.
03:08He added a number of chakras.
03:12Then he added b multiplied by d.
03:15Then he added a number of chakras and then he added a number of chakras and then he added a
03:19number of chakras.
03:20What I can say is that when I started slow and fast,
03:25Fast distance is equal to 2 times slow.
03:30Slow is a little distance.
03:32Fast is a lot of chakras.
03:35Fast will be twice the distance.
03:38So we apply it here.
03:41How much distance is fast?
03:42Fast distance is x plus b into d plus y.
03:46Slow distance is slow?
03:47Slow distance is x plus ad plus y.
03:51I will multiply it with 2.
03:52Then I have this equation.
03:55If I solve this equation,
03:57What can I say?
03:59x plus y is equal to my bd minus 2ad.
04:05Or my x is equal to d.
04:08I have common.
04:09I have taken b minus 2a minus y.
04:12Now this is b.
04:13This is also my constant.
04:15How many chakras will be a constant value?
04:17This is also a constant value.
04:19b minus 2a is a constant value of k.
04:22Like we had replaced in math.
04:23So what can I say?
04:25That my x is equal to kd minus y.
04:30This is the most important equation.
04:33To prove.
04:33Where my x distance is always equal to kd minus y.
04:39I can change the form of kd minus y.
04:42I can change it.
04:43This is equal to k minus 1 into d.
04:47Plus d minus y.
04:50What did I do?
04:51I wrote kd.
04:52k minus 1 d.
04:53Plus d.
04:54So k minus 1 d.
04:55That means the loop of this d distance.
04:58Or this cycle.
04:59To travel k minus 1 times.
05:01I have understood.
05:02How much distance is d minus y?
05:05This distance is d minus y.
05:06So what can I say?
05:08What time is slow?
05:10As long as x is covered.
05:13At that time.
05:14My d minus y.
05:16Plus.
05:17This distance is covered.
05:18This means.
05:19If one pointer is so much distance.
05:22And both are the same speed.
05:23Then the other pointer will be so much distance.
05:25So if I go to this slow pointer.
05:27If I go to this slow pointer.
05:31I go to the head.
05:31And I go to this distance.
05:33And it will come here.
05:34So I go to this fast pointer.
05:36As long as slow.
05:37As long as slow.
05:55This distance is equal to d minus y.
06:05This distance is equal to d minus y.
06:07If we start here.
06:09Logically.
06:10We start here.
06:11And we start here.
06:13And we start here.
06:14And we start here.
06:15And we start here.
06:15And we start here.
06:16And we start here.
06:17Which is the point of creation of my cycle.
06:20In a linked list.
06:21So the proof is very mathematical.
06:25I will not suggest you.
06:26I will not suggest you.
06:28But we start to think intuitively.
06:30We start to think intuitively.
06:30In the notes.
06:31You should write it.
06:32So in the explanation.
06:33When we start to revise the next time.
06:35Then we will remember.
06:36And we will remember.
06:37I will not touch the proof.
06:38I will just understand.
06:39If you understand.
06:40Then we will remember the solution.
06:41What I will understand.
06:43I will understand.
06:44Mathematically.
06:44I have proved that.
06:45Any pointer will be so much distance.
06:47Traveled.
06:48So the other pointer.
06:50K-1 loops.
06:51It will reach here.
06:53And luckily.
06:54I have two pointers.
06:56I have before.
06:57Slow.
06:58Because it was here.
06:59So I have said.
06:59I have put here.
07:00And it will meet.
07:05So this is my mathematical proof.
07:08For removing a cycle.
07:10In a linked list.