﻿1
00:00:00,400 --> 00:00:08,830
‫So the binary tree we looked at in the last video was a binary tree, but it wasn't a binary search

2
00:00:08,830 --> 00:00:09,610
‫tree.

3
00:00:10,150 --> 00:00:14,950
‫In order for it to be a binary search tree, the nodes have to be laid out in a particular way.

4
00:00:15,340 --> 00:00:16,930
‫So let's take a look at that.

5
00:00:17,290 --> 00:00:25,420
‫So let's say we have one node in our tree and we're going to add another node with a binary search tree.

6
00:00:25,930 --> 00:00:30,220
‫If the number is greater, then it's going to go on the right of that node.

7
00:00:30,520 --> 00:00:34,600
‫And if it's less, then it's going to go on the left of that node.

8
00:00:34,930 --> 00:00:39,640
‫And because 76 is greater, then we're going to place it there.

9
00:00:40,120 --> 00:00:42,220
‫Now, let's take a look at another node.

10
00:00:42,580 --> 00:00:50,260
‫The 52 is greater than 47, and we're always going to start by comparing it to the node at the top.

11
00:00:51,320 --> 00:00:55,910
‫And because it's greater, then we're going to go to the right.

12
00:00:56,450 --> 00:00:58,310
‫But there's already a node there.

13
00:00:58,880 --> 00:01:06,260
‫So what we're going to do is we're going to compare that 52 to the 76 and because it's less than 76.

14
00:01:07,090 --> 00:01:10,090
‫That goes on the left of that node.

15
00:01:10,910 --> 00:01:13,760
‫So let's look at another node, a 21.

16
00:01:13,790 --> 00:01:20,360
‫We're always going to start at the top and because the spot to the left of the 47 is open.

17
00:01:21,270 --> 00:01:22,530
‫We'll place it right there.

18
00:01:22,830 --> 00:01:24,930
‫So let's just look at a few more here.

19
00:01:25,590 --> 00:01:27,000
‫We'll say 82.

20
00:01:27,360 --> 00:01:28,680
‫We'll start at the 47.

21
00:01:28,680 --> 00:01:30,690
‫It's greater than we'll go to the right.

22
00:01:30,900 --> 00:01:32,640
‫We'll compare it to the 76.

23
00:01:32,640 --> 00:01:36,990
‫It's greater than again, in this case, that spot is open.

24
00:01:37,290 --> 00:01:38,400
‫So we'll place it.

25
00:01:39,490 --> 00:01:40,330
‫18.

26
00:01:40,660 --> 00:01:43,140
‫It is less than 47.

27
00:01:43,150 --> 00:01:46,450
‫So we go to the left and we look at the 21.

28
00:01:46,450 --> 00:01:49,480
‫It's less than the 21 that spots open.

29
00:01:49,480 --> 00:01:50,890
‫So we'll place that there.

30
00:01:51,250 --> 00:01:55,330
‫And one final node, we'll start at the 47.

31
00:01:55,330 --> 00:01:59,200
‫It's less than we go left to the 21.

32
00:01:59,770 --> 00:02:02,440
‫27 is greater than the 21.

33
00:02:02,950 --> 00:02:05,350
‫So we place that on the right.

34
00:02:06,670 --> 00:02:10,390
‫So a couple of things to point out about a binary search tree.

35
00:02:10,810 --> 00:02:19,930
‫If you take any node in the binary search tree, all nodes below it to the right are going to be greater

36
00:02:19,930 --> 00:02:21,670
‫than that node.

37
00:02:22,450 --> 00:02:26,350
‫Everything on the left is going to be less than.

38
00:02:27,910 --> 00:02:29,530
‫And that is our overview.

39
00:02:30,510 --> 00:02:31,980
‫A binary search tree's.

