﻿1
00:00:00,440 --> 00:00:06,620
‫In this video, we're going to do an introduction of depth first search preorder.

2
00:00:07,040 --> 00:00:12,650
‫And after we do pre-order, we're also going to do post order and in order.

3
00:00:12,980 --> 00:00:18,620
‫So I'm going to bring up a tree and with pre order we're going to start at the root and we're going

4
00:00:18,620 --> 00:00:24,500
‫to output the value 47 and we're always going to go to the left first.

5
00:00:24,500 --> 00:00:32,030
‫So we'll go left and output 21 and then we'll go to the left again and output the 18.

6
00:00:32,330 --> 00:00:35,990
‫Now the 18 is going to try to go left, but there's not a node there.

7
00:00:35,990 --> 00:00:39,530
‫Then it will try to go right and there's not a node there either.

8
00:00:39,530 --> 00:00:44,180
‫So we're done with the 18 and then we come back up to the 21.

9
00:00:44,180 --> 00:00:45,710
‫It has already gone left.

10
00:00:45,710 --> 00:00:52,040
‫Now it's going to go right to the 27 and the 27 is going to look left and look right.

11
00:00:52,250 --> 00:00:57,590
‫And then we come back up to the 21 and then we're going to go all the way back up to the 47.

12
00:00:57,590 --> 00:00:59,150
‫It has already gone left.

13
00:00:59,150 --> 00:01:02,360
‫Now it's going to go right to the 76.

14
00:01:02,780 --> 00:01:06,230
‫And as I mentioned, we're always going to go left first.

15
00:01:06,230 --> 00:01:08,750
‫So we're going to go to the 52 now.

16
00:01:08,750 --> 00:01:12,380
‫We're going to come back up to the 76, which has already gone left.

17
00:01:12,380 --> 00:01:15,830
‫Now it's going to go right and print out the 82.

18
00:01:16,310 --> 00:01:21,620
‫So this will also be our first tree traversal function to use recursion.

19
00:01:22,130 --> 00:01:25,280
‫But for now that is our introduction to depth.

20
00:01:25,280 --> 00:01:27,980
‫First Search Preorder.

