00:01
So for this question we have to write the dynamic program.
00:04
Dynamic program or programming algorithm.
00:15
Let me write it as algo.
00:17
So we have to write a program.
00:21
So algorithm, algorithm min cost will be nm location.
00:38
So in this under we will have, we will have the size.
00:44
Firstly we will write for the new location, that is the new location which will be 0, equal to 0 where u location, u and in under we have.
01:04
So basically the size will be, the size will be equal to, it is given in the question that is m plus 2.
01:13
So the cost of, the cost and the size of size will be equal to 0.
01:25
Now for the len, it will be equal to 3 to size do.
01:36
Now similarly for i is equal to 1 to size do and for j, j will be equal to i plus len minus 1.
01:53
Now cost of i, j will be equal to inf.
02:02
Now if, if i, if j is less than equal to size, so this means that for k, for k it will be equal to i plus 1 to j minus 1 do.
02:22
Now new cost will be? the new cost will be equal to the cost of i, k plus the cost of k, j plus the new location, new location which is of j minus the new location, new location which is of i.
02:56
Now the cost of i, j will be equal to min of minimum of cost of i, j with the new cost, new cost...