Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:08,130 --> 00:00:13,870
‫In this episode we're going to talk about greedy algorithms sometimes when they can be good and other
2
00:00:13,870 --> 00:00:18,370
‫times when they can be bad in terms of mapping applications.
3
00:00:18,490 --> 00:00:27,610
‫And so the problem that we're going to work with is a mapping application where we have a star here
4
00:00:27,950 --> 00:00:36,800
‫and then in the first problem where we have an end here now a greedy over to them remember it always
5
00:00:36,800 --> 00:00:39,850
‫takes the optimal path first.
6
00:00:39,860 --> 00:00:45,890
‫So if you're looking for the shortest path it's going to take the shortest path over and over and over
7
00:00:45,890 --> 00:00:46,220
‫again.
8
00:00:46,220 --> 00:00:53,930
‫So if we created a path that looked something like this
9
00:00:56,940 --> 00:01:07,920
‫then we're taking step one then turning step two and going up first three the side for four or five
10
00:01:08,340 --> 00:01:09,270
‫side for six.
11
00:01:09,270 --> 00:01:14,340
‫All the way until we get to the end.
12
00:01:14,430 --> 00:01:17,690
‫And in this case the greedy algorithm would work.
13
00:01:17,790 --> 00:01:25,950
‫And if you think you can this is something that gets proposed in a lot of quizzes and different algorithm
14
00:01:25,970 --> 00:01:30,450
‫exams is asking if the shortest path.
15
00:01:31,080 --> 00:01:37,950
‫If they agree on a that works with the shortest path and your first inclination may be to say yes if
16
00:01:37,950 --> 00:01:42,450
‫you're creating a mapping application taking the shortest path over and over and over again does seem
17
00:01:42,450 --> 00:01:43,740
‫like the smart way.
18
00:01:43,860 --> 00:01:53,000
‫How ever there is a lot of different cases where this would actually be a horrible idea.
19
00:01:53,310 --> 00:01:57,810
‫And I'll show you one of the best examples I've seen for it.
20
00:01:58,020 --> 00:02:05,430
‫And so we're going to say the start is right here and we're going to put the end here so you can think
21
00:02:05,430 --> 00:02:12,190
‫of these two different points on the map and we'll draw out some different roads.
22
00:02:12,300 --> 00:02:23,260
‫So we're going to draw out roads that go something like this.
23
00:02:23,420 --> 00:02:24,590
‫So that's one road.
24
00:02:24,720 --> 00:02:34,190
‫And obviously because this is the shortest path we would take this one first then go and then keep on
25
00:02:34,190 --> 00:02:37,670
‫going because the greedy algorithm would always take the shortest path first.
26
00:02:37,670 --> 00:02:46,460
‫However in this case if there was a road that went straight right here to the end this would actually
27
00:02:46,460 --> 00:02:48,770
‫be the optimal path.
28
00:02:48,830 --> 00:02:56,030
‫This would be the way to go agree the algorithm though would not even consider this an option because
29
00:02:56,090 --> 00:03:04,080
‫it would see the distance here as being greater than the distance right here.
30
00:03:04,150 --> 00:03:08,530
‫And so it would always choose this option.
31
00:03:08,540 --> 00:03:14,530
‫And so your greedy algorithm would actually go all the way around in order to get to the end.
32
00:03:14,540 --> 00:03:19,100
‫And so in this case the greedy algorithm would be a very poor choice.
33
00:03:19,130 --> 00:03:26,780
‫And this is something I've seen on different exams for analysis of algorithm problems and it's something
34
00:03:26,780 --> 00:03:32,070
‫that I initially got wrong and was able to learn from it.
35
00:03:32,130 --> 00:03:37,400
‫So make sure whenever you're asked this question you really think it all the way through and realize
36
00:03:37,400 --> 00:03:43,370
‫that you know you need to know your data sources and you need to also think of some of the worst case
37
00:03:43,370 --> 00:03:48,400
‫scenarios in order to know when a greedy algorithm can work and when it can.
4186
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.