00:01
So, in this question, to solve this problem using a greedy algorithm, we can use the nearest neighbor approach.
00:10
So, we are using the nearest neighbor approach.
00:23
So here, at each step, we will select the nearest unvisited location from a current location until all locations have been visited.
00:32
So the return to the starting home, that will be done.
00:36
So, first we will see the greedy algorithm steps, which i will tell you step by step.
00:43
So, first we will see the greedy algorithm steps.
00:55
So in this case, we start from home, that is h.
01:00
So, we will start stepwise, naming it abc.
01:05
So, we will start from home h, that is h.
01:15
Then we find the nearest visited location that is there.
01:20
So we can say that we have to find the nearest location, that is the unvisited location.
01:39
And this we have to find from the current location.
01:44
So from current location, which is important.
01:50
So this is our second step.
01:51
Now, the third step would be to move to that nearest unvisited location.
01:59
So we have to move to this unvisited location.
02:13
So now, next step will be simply this thing, that we have to repeat the steps 2 and 3 until all the locations are visited.
02:23
So we just have to repeat the steps, that is b and c till all the locations that are there, that are visited.
02:42
So now, this is our crucial step, that is we have to return to home to complete the cycle.
02:51
So, this is important.
02:52
We have to return to home, that is h.
02:57
We have to return to home to complete the cycle.
03:01
So this is the greedy algorithm steps that are there.
03:07
Now we will see the number of comparisons in greedy algorithm.
03:13
So to calculate the number of comparisons, we need to find out how many comparisons we make at each step, while finding the nearest unvisited location that is there.
03:27
So considering there are n locations, we have to take an example for that, that considering n locations, that is in the given problem, that is given as 3 in the given problem.
03:45
So in the first step, we need to compare the distances to n -1 locations, that is 2 comparisons in this case.
03:55
So we will see it step by step, that we have to compare the distances.
04:03
So we have to compare the distances to n -1 location, that is 2 comparisons in this case.
04:23
Then secondly, we have to compare the distances to n -2 locations in this case...