text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
And I can stop here, leaving me with just five potential problems.
2,044.38
3.042
And then you can see where this is going.
2,047.422
1.708
2 and 1?
2,049.13
0.5
Let's swap.
2,049.63
0.97
2 and 3?
2,050.6
0.5
You're good.
2,051.1
0.43
3 and 4?
2,051.53
0.55
You're good.
2,052.08
0.67
We already solved these problems.
2,052.75
1.42
So let me go back.
2,054.17
1.61
And now, 1 and 2?
2,055.78
1.22
You're good.
2,057
0.84
2 and 3?
2,057.84
0.54
You're good.
2,058.38
0.56
3 and 4, 4 and 5, 5 and 6, 6 and 7, 7 and 8.
2,058.94
3.14
What do I know now as the computer?
2,062.08
3.61
What's that?
2,065.69
0.56
AUDIENCE: It's sorted.
2,066.25
0.31
SPEAKER 1: It's sorted.
2,066.56
0.958
Why?
2,067.518
0.911
AUDIENCE: Because everything's in order
2,068.429
1.901
SPEAKER 1: Everything is in order.
2,070.33
0.889
But what does that mean?
2,071.219
1
We humans can see that, but the computer can only look at individual values
2,072.219
3.171
at a time.
2,075.39
0.499
It can't take a step back and say, yep, sorted.
2,075.889
2.966
AUDIENCE: [INAUDIBLE].
2,078.855
2.229
SPEAKER 1: Good.
2,081.084
0.666
At a lower level implementation detail, I did no swaps.
2,081.75
3.46
There were no two numbers that were out of order.
2,085.21
2.08
So it would just be foolish of me and wasteful
2,087.29
3.31
for me to bother doing another pass.
2,090.6
1.78
Because assuming the numbers are not changing on their own,
2,092.38
2.67
I'm just going to do the same thing again and again otherwise.
2,095.05
2.583
So I can just stop.
2,097.633
1.227
And indeed, the bubble sort allows us to stop like this.
2,098.86
2.53
Let's do one last approach.
2,101.39
1.29
If you could, let me toss the starting points on the board again.
2,102.68
4.04
Let's reset one last time to this.
2,106.72
3.589
And let me propose-- let me draw inspiration, actually,
2,110.309
2.291
from the approach you took with the blue books, which was
2,112.6
2.374
a little different from how we began.
2,114.974
1.706
Which was recall that you took the problem on your left hand
2,116.68
3.572
and you just dealt with it one at a time.
2,120.252
1.708
You didn't go sifting through looking for A.
2,121.96
1.83
You didn't go sifting through looking for B.
2,123.79
1.7
You didn't go sifting through looking for C, which would really
2,125.49
2.11
be the analog of what you proposed a moment ago.
2,127.6
2.12
Instead, you just dealt with each problem as it came.
2,129.72
2.23
And this is our third and final algorithm
2,131.95
1.94
for sorting called insertion sort.
2,133.89
2.53
Take each problem one at a time and just deal with it then and there.
2,136.42
3.85
Don't postpone.
2,140.27
1.1
So here's 4.
2,141.37
0.923
You know what?
2,142.293
1.167
Done.
2,143.46
0.58
I now claim that this list, which we'll visually make a little separate,
2,144.04
3.7
is sorted.
2,147.74
0.85
So I'm going to mentally divide my list into a left half and a right half.
2,148.59
3.14
And now I just claim trivially-- I mean, almost silly-- this is sorted.
2,151.73
4.31
Because it is.
2,156.04
0.83
But now the right half of my list remains.
2,156.87
1.88
So let's go ahead and do this.
2,158.75
1.249
So number 2.
2,159.999
0.931
OK, where does this belong?
2,160.93
1.17
So if you want to go ahead and pick up the number.
2,162.1
2.083
The stand can stay.
2,164.183
1.297
Number 2 goes where?
2,165.48
1.79
Here's my left list.
2,167.27
1.045
And we'll make a little more space here just to be clear.
2,168.315
2.375
It goes over to this side.
2,170.69
1.6
So what has to happen?
2,172.29
2.74
So this time, we do need to shift you over.
2,175.03
2.84
So let's take 2 out.
2,177.87
1.37
Let's shift 4 over.
2,179.24
2.017
And now we won't move the stand.
2,181.257
1.333
We'll just assume now that my left half is of size 2
2,182.59
3.25
and the right half is of size 6.
2,185.84
1.445
But now, the left half of the list is still sorted,
2,187.285
2.125
but it costs me a little bit of work.
2,189.41
1.541
I had to move 4 over.
2,190.951
1.32
All right, let me deal with 6.
2,192.271
1.249
Where does 6 go?
2,193.52
1.684
It's already in order.
2,195.204
0.916
I don't need to shift anyone.
2,196.12
1.208
Where does 8 go?
2,197.328
0.792
Phew, it doesn't need to go anywhere.
2,198.12
1.541
It's already in order.
2,199.661
0.935
Uh-oh, 1.
2,200.596
0.774
Where does it go?
2,201.37
0.94
Now we incur a good amount of cost.
2,202.31
2.052
So let's do this.
2,204.362
0.708
Where do you go?
2,205.07
1.19
One shift, two shift, three shifts, four shifts.
2,206.26
3.8
Feels-- yep-- as bad as our original approach.
2,210.06
3.49
But notice I only have 4 more problems left.
2,213.55
1.979
I don't have to keep going back through the list.
2,215.529
2.041
So where does 3 go?
2,217.57
0.75
All right, let's pop you out.
2,218.32
1.208
Shift you in there.
2,219.528
1.862