text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
you're seeing in the middle is too big,
then search the left half of the array. | 755.7 | 4.69 |
Else if the element is to the
right, as it was in Derek's case, | 760.39 | 3.3 |
search the right half of the
array, else return false. | 763.69 | 4.16 |
But there is no go-to instruction here. | 767.85 | 2.27 |
And there's no line numbers. | 770.12 | 1.206 |
Recall from week 0 when we
searched for Mike Smith, | 771.326 | 2.124 |
I deliberately numbered
all of the lines. | 773.45 | 1.93 |
And then I said, go back to
step 2 or 3 I think it was. | 775.38 | 4.08 |
Here, I seem to be cutting a corner. | 779.46 | 2.13 |
I'm just kind of waving
my hand and saying, | 781.59 | 2.106 |
search the left half of the list. | 783.696 | 1.374 |
Or, search the right half of the list. | 785.07 | 2 |
But what algorithm should we
use in either of these cases? | 787.07 | 3.66 |
How do you search the
left half of a list? | 793.62 | 2.03 |
How do you search the
right half of a list? | 795.65 | 1.855 |
How do I do this? | 801.13 | 1.72 |
Well, where do I have an
algorithm for searching? | 802.85 | 2.49 |
Well, we saw one a moment ago. | 805.34 | 1.47 |
I've already got in my toolkit,
so to speak, linear search. | 806.81 | 2.9 |
So I could certainly use that. | 809.71 | 1.31 |
But sort of cyclically,
or sort of confusingly, | 811.02 | 3.15 |
I also have this other seemingly
fancier, faster algorithm | 814.17 | 3.09 |
called binary search. | 817.26 | 1.2 |
And yet, I'm in the middle of defining
binary search with my pseudocode. | 818.46 | 4.46 |
And yet, here I am sort of trying
to define myself with myself. | 822.92 | 3.234 |
You can't get away with this in English. | 826.154 | 1.666 |
If you're asked to
define an English word | 827.82 | 1.74 |
and you use the word in the definition,
usually a teacher or someone | 829.56 | 2.96 |
in a conversation will sort of
verbally slap you on the wrist | 832.52 | 2.35 |
because you're not
answering the question. | 834.87 | 1.75 |
And yet somehow in programming,
you can get away with this. | 836.62 | 3.61 |
Somehow, you can get away with defining
a problem with a solution like this, | 840.23 | 5.62 |
and then using that same
solution inside of your solution | 845.85 | 2.95 |
because something is changing. | 848.8 | 2.66 |
This line here, search the
left half of the array, | 851.46 | 2.54 |
and this line here, search
right half of the array, | 854 | 2.4 |
is not equivalent to asking
the same question again. | 856.4 | 4.24 |
Is this element in the array? | 860.64 | 1.65 |
What changes when I either search
the left half or the right half that | 862.29 | 4.38 |
makes this acceptable? | 866.67 | 2.26 |
AUDIENCE: [INAUDIBLE]. | 868.93 | 1.427 |
SPEAKER 1: What's that? | 870.357 | 0.958 |
AUDIENCE: [INAUDIBLE]. | 871.315 | 2.475 |
SPEAKER 1: Yes. | 873.79 | 0.93 |
That's the key ingredient. | 874.72 | 1.18 |
In so far as search left half
and search right half imply | 875.9 | 3.8 |
search in the same way, but
search a smaller problem, | 879.7 | 3.77 |
this problem will eventually stop. | 883.47 | 1.82 |
You're not going to get stuck
in an infinite loop so to speak. | 885.29 | 2.583 |
Because eventually-- you
can't half something forever. | 887.873 | 2.467 |
You're eventually going to end
up with one or zero elements. | 890.34 | 2.17 |
At which point, the
answer's going to be no. | 892.51 | 1.833 |
Return false, it's not here
per the else condition. | 894.343 | 2.657 |
But these sort of reflexive
calls or inductive, | 897 | 4.78 |
or more properly here, recursive
calls-- the new buzzword | 901.78 | 3.48 |
for today-- means for a function, or in
this case pseudocode, to call itself. | 905.26 | 5.4 |
To use its own definition
again and again | 910.66 | 2.45 |
and again, which is bad instinctively,
unless you keep doing it | 913.11 | 3.53 |
on smaller and smaller problems. | 916.64 | 2.3 |
And so this is a general
principle, actually, | 918.94 | 2.31 |
that we're going to be able to leverage
ultimately, not only for searching but | 921.25 | 3.41 |
also, as we shall see, for sorting. | 924.66 | 3.49 |
So let's go ahead and
let me share actually | 928.15 | 2.48 |
how this example went last year. | 930.63 | 1.48 |
We're fortunate to capture
sort of memories on film. | 932.11 | 2.52 |
And I thought it would
be fun to share this, | 934.63 | 1.985 |
when one of your predecessors
in the class came up, | 936.615 | 2.525 |
was asked the exact same
question, find us the number 50. | 939.14 | 2.92 |
But it didn't quite go
as well as we hoped. | 942.06 | 2.61 |
Let's take a look at 2014. | 944.67 | 1.934 |
[AUDIO PLAYBACK] | 946.604 | 0.666 |
-All I want you to do now is
to find for me and for us, | 947.27 | 3.65 |
really, the number 50
one step at a time. | 950.92 | 5.935 |
-Number 50? | 956.855 | 1.155 |
-The number 50. | 958.01 | 0.74 |
And you can reveal what's
behind each of these doors | 958.75 | 2.166 |
simply by touching it with a finger. | 960.916 | 3.184 |
Damn it. | 964.1 | 2.34 |
[APPLAUSE] | 966.44 | 2.151 |
[END PLAYBACK] | 968.591 | 0.656 |
SPEAKER 1: OK. | 969.247 | 0.583 |
So that didn't really
demonstrate anything that year. | 969.83 | 2.208 |
So we tried again, this time saying, all
right, this time the array is sorted. | 972.038 | 4.202 |
What are you going to do this time if
you want to find the same number 50, | 976.24 | 3.24 |
but the array is now sorted? | 979.48 | 1.76 |
I thought I'd share this. | 981.24 | 1.463 |
[AUDIO PLAYBACK] | 982.703 | 0.887 |
-The goal now is to also find us the
number 50, but do it algorithmically. | 983.59 | 4.31 |
And tell us how you're going about it. | 987.9 | 2.55 |
And if you find it, you keep the movie. | 990.45 | 2.17 |
If you don't find it, you give it back. | 992.62 | 1.924 |
-Man. [INAUDIBLE]. | 994.544 | 1.828 |
OK. | 996.372 | 0.918 |
So I'm going to check the ends
first to determine if there's-- oh. | 997.29 | 5.23 |
[APPLAUSE] | 1,002.52 | 2.742 |
[END PLAYBACK] | 1,005.761 | 0.929 |
SPEAKER 1: OK, now I feel a
little bad because clearly we | 1,006.69 | 1.38 |
used to give away movies and
now we give away stress balls. | 1,008.07 | 2.64 |
But no one really has DVD players
anymore, so it's OK probably. | 1,010.71 | 3.12 |
And then, let me share one other
clip back from our SD days. | 1,013.83 | 3.32 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.