00:01
They want us to use hoffman coding to encode the symbols given the frequencies, and then figure out how many bits on average we will need to use in order to encode any letter.
00:13
So the first thing we want to do is start to make some trees.
00:18
So let's go ahead and do that.
00:19
We could just make a tree for each of these.
00:23
Single letters first.
00:25
So we're going to have an a, b, c, d.
00:31
E, f, and g.
00:33
And then above these, let's put their frequencies.
00:40
So we have 0 .1, 0 .25, 0 .05, 0 .15, 0 .15, 0 .3, 0 .07, and then 0 .08.
00:59
So these are going to be the frequencies that we're given.
01:02
Now, what we want to do is identify what is the two smallest frequencies that we have.
01:09
Well, in this case, that's going to be 0 .05 with c and 0 .07 with f.
01:20
Now, what the hoffman coding tells us to do is put the larger of these to the left, like this.
01:31
And then we create a tree for these.
01:38
So f is going to be zero and c is going to be one.
01:41
Then we would want to add these frequencies together, so that's going to be 0 .12.
01:49
So now let's go ahead and get rid of these old frequencies, and then we can go ahead and move these two letters up.
01:58
So now what we can do at this point is just go ahead and throw that back in line and then compare all of these, like we did at the start.
02:12
So we have 0 .1, 0 .8, and 0 .12.
02:17
So it looks like that's going to be 0 .08 and 0 .1 .1.
02:24
So these are going to be the two that we're comparing.
02:28
So we want to put our more frequent one to the left, our less frequent one to the right.
02:35
Looks like 0 .1 is already there for a, and then 0 .08 is to the right.
02:40
So that looks good.
02:43
So that means a is 0, and 1 is going to be g.
02:47
So again, let's go ahead and erase these frequencies right here.
02:52
And scoot our letters up a little bit.
03:05
And so a and g, so a was 0 .1, and g was 0 .8.
03:10
So this should be 0 .18.
03:16
Now we're going to throw this back in line.
03:21
So we have 0 .25, 0 .15.
03:27
So it looks like it's going to be 0 .15 and then 0 .12.
03:34
So we're going to have these two.
03:36
So again, remember, we want the more frequent to left, which we have here, and the less frequent to the right, which we have.
03:45
So that means d is going to be 1.
03:48
And then this tree over here, or i'm sorry, d is going to be zero, and then this tree over here is going to be one.
03:54
So then we would add those two frequencies up, which is going to be 0 .27.
03:59
And then let's go ahead and get rid of those old frequencies, and then we can go ahead and scoot up d, and then we can also scoot this tree up over here.
04:17
And then again, we're going to throw this back in line with the other ones.
04:22
So i'll just throw this over here on the left.
04:26
And now we need to compare these.
04:28
Well, that looks like we would have 0 .25 and 0 .18.
04:35
So now we create a new tree for these pair.
04:42
So that would be b on the left since it's more frequent, and then the ag tree to the right since it's only 0 .8.
04:54
So we have 0 .1.
05:00
And then we would add these up, and this is going to be 0 .43 for the frequency.
05:09
Now we can go ahead and erase these, and then move these letters up, and then move this tree over here up.
05:24
And then we're going to compare these three.
05:29
And so that would be 0 .3 for e.
05:34
And then 0 .27 for this tree that we have over here.
05:39
And then i'm just going to move this to the right.
05:45
And i'll just scoot this up.
05:48
All right, so we make a tree here...