text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
shrink the font size or increase the margins.
4,511.72
1.95
Or maybe more realistically you write a five page paper that's
4,513.67
2.732
supposed to be a 10 page paper, and so you increase the font size
4,516.402
2.708
or increase the margins so as to expand or decompress the essay.
4,519.11
5.86
So, similarly here, what if we wanted to compress text,
4,524.97
4.57
but we want to do it losslessly in a way that we
4,529.54
2.9
don't lose any information by just throwing away
4,532.44
2.21
characters, or paragraphs, or pages, but we
4,534.65
4.214
want to use the system with which we're familiar from week zero.
4,538.864
2.666
So ASCII, again, is just this code, this mapping of letters to numbers.
4,541.53
3.38
And so, A is-- capital A is 65 and that's some pattern of bits,
4,544.91
4.07
but it's some pattern of 8 bits-- 7 historically,
4,548.98
3.13
but really 8 bits in practice So every one
4,552.11
2.94
of the characters in the English alphabet, at least here,
4,555.05
3.68
takes up 8 bits.
4,558.73
2.16
Now, that sounds fine.
4,560.89
1.1
That allows us to express as many as 256 possible characters, which
4,561.99
3.25
is more than enough for English characters, plus some punctuation
4,565.24
2.74
and so forth.
4,567.98
1.18
But it seems wasteful.
4,569.16
2.23
I type A, E, and I, maybe O and U pretty often.
4,571.39
3.24
I use the values often-- the vowels often.
4,574.63
3.778
B and D, I feel like I use those a lot.
4,578.408
2.852
I don't really type Q all that much, Z all that much.
4,581.26
4.31
So, there are certain letters that I just
4,585.57
1.735
feel like I don't type them that often, and indeed,
4,587.305
2.125
probably if we analyzed a dictionary, we wouldn't see them as frequently
4,589.43
3.24
as other letters.
4,592.67
0.82
Indeed, if you've ever played or watched Wheel of Fortune,
4,593.49
2.5
certainly all the contestants on that show
4,595.99
2.04
know which are the most popular letters in English words.
4,598.03
3.48
And it seems silly and perhaps inefficient--
4,601.51
3.33
certainly for a computer scientist-- that we are not somehow
4,604.84
2.65
embracing the fact that some letters are more commonly used than others,
4,607.49
4.37
and yet we are just blindly using 8 bits, the same amount of memory,
4,611.86
3.92
for every darn letter in our alphabet.
4,615.78
1.71
Why?
4,617.49
0.9
If you keep writing a certain letter again and again,
4,618.39
2.29
why not use fewer bits for the more popular letters,
4,620.68
3.12
and more bits for the less popular letters
4,623.8
2.24
so that at least you're optimizing for the common case, so to speak?
4,626.04
4.61
Well, it turns out that someone named Huffman years ago did
4,630.65
3.31
figure this out and introduced what's generally known as Huffman coding.
4,633.96
3.61
And, at first glance, it's a little similar in spirit to something
4,637.57
2.84
some of you might have grown up learning a little something about called Morse
4,640.41
3.249
code, but it's better in a couple of ways.
4,643.659
2.141
Morse code typically transmitted with electrical signals or audible signals.
4,645.8
5.52
It has dots and dashes where a dot is a quick beep
4,651.32
3.09
and a dash is a slightly longer beep, and you
4,654.41
2.43
can use those series of dots and dashes, as per this chart here,
4,656.84
4.13
to represent letters of the alphabet and some numbers.
4,660.97
3.18
The one problem, though, as efficient as this seems-- and then by efficient
4,664.15
4.4
I mean look at E. Mr. Morse realized that is super popular, so he
4,668.55
4.14
used literally the shortest symbol for it, just a dot, a simple blip,
4,672.69
3.41
to represent an E. And, meanwhile, as I kind of imagined,
4,676.1
2.99
Z is not that common, so dash, dash, dot,
4,679.09
3.47
dot is longer than just a single dot.
4,682.56
2.33
So Z is probably less popular, and that's why we did this.
4,684.89
2.59
And Y may be even less popular-- dash, dot, dash--
4,687.48
3.437
I don't know why I'm using this voice.
4,690.917
1.583
But it's longer than E, so we optimized for the shorter characters.
4,692.5
5.056
Unfortunately, suppose that you receive the message dot, dot, dot, dot, dot,
4,697.556
10.064
dot, so six dots in a row, and I technically paused in between them.
4,707.62
4.82
Six dots, what message did I just send you?
4,712.44
2.052
4,714.492
3.698
Six dots.
4,718.19
0.76
4,718.95
5.232
So, I wanted to say hi, so I said dot, dot, dot, dot, which is H,
4,724.182
4.068
and then dot, dot which is I. I should not have paused between them,
4,728.25
3.23
because the whole point of Morse code is to do this as quickly as possible,
4,731.48
3.125
even though you probably do want to pause to resolve ambiguity,
4,734.605
3.045
and indeed, that's the problem.
4,737.65
1.53
I wanted to send you hi, H-I, but maybe I
4,739.18
4.03
just sent you E, E, E, E, E, E, six Es in a row,
4,743.21
4.59
because those two were just dots.
4,747.8
1.69
So, in other words, Morse code is not immediately decodable
4,749.49
2.87
when you're reading, or hearing, or seeing the dots and dashes come
4,752.36
3.097
over the wire, so to speak, because there's these ambiguities,
4,755.457
2.583
unless this transmitter does indeed pause,
4,758.04
3.47
as I accidentally did there, to give you a moment to take your breath
4,761.51
3.54
and realize, oh, that was an H. That's an I. As opposed to E, E, E, E, E, E.
4,765.05
4.95
So, it's not necessarily the best system in so far as some letters
4,770
4.02
share prefixes with other letters.
4,774.02
3.03
In other words, I, dot dot, has a common prefix with E. Both of them
4,777.05
4.93
start with a single dot.
4,781.98
1.485
It just so happens that I is a little longer,
4,783.465
1.875
and that can lead potentially to ambiguity,
4,785.34
1.91
and it certainly means that the transmitter should probably slow down.
4,787.25
4.86
So, the whole system is meant to be super fast, super efficient,
4,792.11
2.71
but you probably should pause between certain letters
4,794.82
3.04
so that the recipient doesn't get confused as
4,797.86
1.98
to the message you're actually sending.
4,799.84
2.11
Well, thankfully Huffman coding-- which as we'll see in a moment
4,801.95
3.25
is based on trees-- does not have that ambiguity.
4,805.2
2.6
It is a immediately decodable.
4,807.8
1.76
And suppose for the sake of discussion, as per this example here,
4,809.56
3.06
you just have a whole bunch of text that you want to transmit.
4,812.62
1.87
This is meaningless.
4,814.49
0.833
There's no pattern in these As, and E, B, C, Ds, and Es,
4,815.323
2.787
but if you go through and count them up, each these letters-- A, B, C, D, E--
4,818.11
4.343