Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:08,480 --> 00:00:15,260
‫In the last video you saw how I walk through how to do a breath first search in this video.
2
00:00:15,270 --> 00:00:23,970
‫I'm going to explain how depth first search works and what depth first search is is a nother kind of
3
00:00:24,300 --> 00:00:31,560
‫searching algorithm and it has some very different applications than breath first search and you'll
4
00:00:31,560 --> 00:00:32,920
‫see how it works.
5
00:00:32,970 --> 00:00:40,530
‫When I walk through the actual visualization and one other thing you may if you're familiar with the
6
00:00:40,530 --> 00:00:46,240
‫video I did on post order binary search tree traversals.
7
00:00:46,470 --> 00:00:49,840
‫You're going to see a few similarities between that and this.
8
00:00:49,890 --> 00:00:55,710
‫So I'm going to start off by giving you the properties and what the properties are is you start at the
9
00:00:55,710 --> 00:01:03,220
‫root and you follow the leftmost branch of the tree as far as possible until you either find the new
10
00:01:03,250 --> 00:01:06,280
‫you you're looking for or you hit a leaf node.
11
00:01:06,360 --> 00:01:13,910
‫So as you can see right here we if we start at the root and give that one we follow
12
00:01:16,320 --> 00:01:24,620
‫the leftmost branch so we have a 1 2 3 and a 4.
13
00:01:24,640 --> 00:01:32,650
‫So now we had our leafnode and the second property is if a leaf node is hit continue the search at the
14
00:01:32,650 --> 00:01:36,220
‫nearest ancestor with unexplored children.
15
00:01:36,250 --> 00:01:39,160
‫And so this is a recursive call.
16
00:01:39,160 --> 00:01:46,820
‫And so what it will do is there are no more nodes here because four is a leaf node.
17
00:01:46,870 --> 00:01:56,260
‫So instead we get turn around and go with the closest ancestor which is going to be right here because
18
00:01:56,260 --> 00:02:00,680
‫this is a ancestor is a child of three.
19
00:02:00,690 --> 00:02:03,330
‫And so this will be five.
20
00:02:03,560 --> 00:02:11,710
‫This will be the sixth item that we visit and then we'll go up to 7 8.
21
00:02:11,830 --> 00:02:15,360
‫And now that we're 8 Remember we have this recursive call.
22
00:02:15,370 --> 00:02:22,290
‫So if you ever wonder where you're going to go from here remember were always going to go to the left
23
00:02:22,300 --> 00:02:23,680
‫most note possible.
24
00:02:23,680 --> 00:02:28,410
‫So we're going to come down here to nine ten now.
25
00:02:28,480 --> 00:02:30,410
‫10 is a leaf node.
26
00:02:30,490 --> 00:02:35,980
‫So we simply go to 11 and 12 and that's it.
27
00:02:35,980 --> 00:02:43,480
‫So this is how to do depth first search as you can see it's very different than breadth first search
28
00:02:43,480 --> 00:02:53,410
‫where as with breath first search we started at the root followed down to this level to the third level
29
00:02:53,710 --> 00:02:54,870
‫into the fourth.
30
00:02:55,000 --> 00:03:00,210
‫And some of the numbering differences this is the root is always one.
31
00:03:00,250 --> 00:03:12,940
‫But in the infer breath first search this eight was actually a four because it went one two three and
32
00:03:12,940 --> 00:03:15,800
‫then four right here.
33
00:03:15,970 --> 00:03:23,080
‫So that's a very important thing to know depth first search has a completely different use case then
34
00:03:23,080 --> 00:03:23,970
‫breath first.
35
00:03:23,970 --> 00:03:31,180
‫There are both data structures or algorithms that are extremely popular for certain applications.
36
00:03:31,180 --> 00:03:38,170
‫I personally don't I haven't really found a need to use breadth first search or depth first search in
37
00:03:38,490 --> 00:03:44,530
‫and day to day development but that's mainly because I build out Web applications and mobile applications
38
00:03:44,530 --> 00:03:51,430
‫and these usually aren't used for camping or more just things that you learn to learn more about computer
39
00:03:51,430 --> 00:03:57,250
‫science and algorithm development so they're good to have a solid understanding of but they're not things
40
00:03:57,250 --> 00:04:03,560
‫that you're going to use on a day in day out basis unless you focus in on that as a specialty so that's
41
00:04:03,560 --> 00:04:04,480
‫depth first search.
42
00:04:04,480 --> 00:04:08,340
‫Please let me know if you have any questions whatsoever and I'll see the next video.
4682
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.