text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
So, Scully here represents first,
and indeed her sheet of paper | 1,306.26 | 3.11 |
is horizontal to suggest
that she is just a node. | 1,309.37 | 2.71 |
She is just going to be the
pointer of to a node in a list. | 1,312.08 | 3.69 |
Everyone else's nodes
are vertical, as have | 1,315.77 | 1.972 |
been the rectangles we've
been drawing on the screen, | 1,317.742 | 2.208 |
because each of these guys represents
a number as well as a next pointer. | 1,319.95 | 4.4 |
Now of course, you're only seeing
in front of you the number. | 1,324.35 | 2.59 |
So we're going to go ahead
and if you wouldn't mind, | 1,326.94 | 1.56 |
use your left hand to represent the
arrow that we've long had on the screen | 1,328.5 | 3.67 |
to point to the person next to you. | 1,332.17 | 1.65 |
And Erin, you're a bit
of an anomaly, but also | 1,333.82 | 2.86 |
because you need to have a null
pointer at the end of the list, | 1,336.68 | 3.079 |
so that you're not just
pointing aimlessly. | 1,339.759 | 1.791 |
And pointing to the ground
seems fine, so literally | 1,341.55 | 2.27 |
pointing to the ground will
represent-- will infer as null. | 1,343.82 | 4.3 |
So, Scully, you are the only
thing keeping this list together, | 1,348.12 | 2.75 |
so to speak. | 1,350.87 | 0.64 |
So, you two need to point with
your one pointer to Maria there. | 1,351.51 | 4.48 |
So, here we have a linked list. | 1,355.99 | 1.88 |
And just to make this clear, could
everyone separate from each other | 1,357.87 | 3.26 |
by a step or two in any direction? | 1,361.13 | 2.58 |
Notice that the list is still--
it's almost identical to before. | 1,363.71 | 3.319 |
Can some of you take a
step forward, a step back, | 1,367.029 | 2.041 |
but still point at the other person? | 1,369.07 | 1.94 |
So, now we're capturing a
little more accurately the fact | 1,371.01 | 2.53 |
that these nodes and these
pointers can be anywhere in memory, | 1,373.54 | 3.11 |
so long as they're linking themselves
together by way of these pointers. | 1,376.65 | 4.43 |
All right, so suppose
now that I want to insert | 1,381.08 | 2.24 |
an element like 55, which happens
to belong at the end of this list. | 1,383.32 | 5.27 |
Let me go ahead and malloc
Christian if I could. | 1,388.59 | 3.82 |
So we have asked malloc for
a chunk of memory equivalent | 1,392.41 | 2.6 |
to the size of one
integer and one pointer. | 1,395.01 | 2.81 |
That is going to be represented
with this rectangle here. | 1,397.82 | 2.53 |
Nice to see you. | 1,400.35 | 0.796 |
AUDIENCE: Nice to see you. | 1,401.146 | 0.406 |
SPEAKER 1: You shall be 55. | 1,401.552 | 1.448 |
And I'll play the role of the temporary
pointer as predecessor pointer | 1,403 | 3.069 |
or pointer just using
my left or right hand | 1,406.069 | 1.791 |
to try to figure out
where Christian belongs. | 1,407.86 | 3.06 |
So, just like you might-- just like
we might want to search the list, | 1,410.92 | 5.45 |
inserting is fundamentally
rather the same. | 1,416.37 | 2.75 |
The only thing I have access to
at the outset of this algorithm | 1,419.12 | 2.82 |
is my first pointer, and
it's only by way of Scully | 1,421.94 | 2.74 |
that I can even access
the rest of the list. | 1,424.68 | 1.95 |
I cannot jump to the
middle, jump to the end. | 1,426.63 | 2.3 |
I can only start at the beginning
and literally follow the pointer. | 1,428.93 | 3.377 |
So, let me go ahead and do that. | 1,432.307 | 1.333 |
Let me go ahead and
point at whatever Scully | 1,433.64 | 1.37 |
is pointing at, which happens to
be Maria, which is the number 9. | 1,435.01 | 3.066 |
55, of course, is
bigger than that, and I | 1,438.076 | 2.134 |
do want to keep the list
sorted for today's purposes. | 1,440.21 | 2.34 |
So I'm going to very carefully
follow the next pointer, 17. | 1,442.55 | 4.32 |
Follow the next pointer, 20. | 1,446.87 | 1.5 |
Follow the next pointer, 22. | 1,448.37 | 1.75 |
Follow the next pointer, 29. | 1,450.12 | 1.84 |
Follow the next pointer, 34. | 1,451.96 | 1.83 |
Follow the next pointer,
ah dammit, null. | 1,453.79 | 2.844 |
And so this is why it is important
with some of these algorithms | 1,456.634 | 2.666 |
to have a predecessor pointer, a
second pointer or really my left hand | 1,459.3 | 4.15 |
so that maybe my left hand
can still point at Erin. | 1,463.45 | 2.71 |
My right hand can realize,
ah, null, so that I still | 1,466.16 | 3.46 |
have access to the last node
in the list so that Christian-- | 1,469.62 | 2.92 |
if you could come over here. | 1,472.54 | 1.73 |
I'm going to go ahead and tell Erin
quite simply to point at Christian. | 1,474.27 | 6.48 |
Good, and let's just say for
students' sake come on over here, | 1,480.75 | 4.045 |
but technically we could have
left Christian there and just had | 1,484.795 | 2.625 |
Erin pointing at him. | 1,487.42 | 0.89 |
It's just going to get a
little confusing before long, | 1,488.31 | 2.25 |
so we'll just cheat and
move you right over here. | 1,490.56 | 2.299 |
But now we have a linked list
that has one additional member. | 1,492.859 | 2.541 |
Suppose now that we want to
make another insertion-- pardon. | 1,495.4 | 4.03 |
Let me go ahead and propose
that we insert say the number 5. | 1,499.43 | 4.86 |
Well, the number 5, of course,
belongs at the beginning of the list. | 1,504.29 | 5.6 |
So you know what? | 1,509.89 | 0.71 |
I need to malloc. | 1,510.6 | 1.02 |
Can I malloc Jordan off
camera five, perhaps? | 1,511.62 | 4.506 |
So malloc, a very slow return value. | 1,516.126 | 2.684 |
OK, we're going to store your
node your n value five here. | 1,518.81 | 4.12 |
His pointer is undefined right
now, because he's not actually | 1,522.93 | 2.6 |
pointing at anything. | 1,525.53 | 0.99 |
And so where does he ultimately belong? | 1,526.52 | 1.911 |
Well, he belongs at
the start of the list. | 1,528.431 | 1.749 |
So, let me deliberately make a mistake. | 1,530.18 | 2.03 |
Let me go ahead and update
Scully to point at Jordan, | 1,532.21 | 3.24 |
thereby putting Jordan effectively
at the front of the list. | 1,535.45 | 2.75 |
Unfortunately, whom should
Jordan now point at technically? | 1,538.2 | 4.62 |
It should be Maria, but this is code. | 1,542.82 | 3.52 |
The only thing we can do
is copy pointers in memory, | 1,546.34 | 2.66 |
and if Scully's left hand is
no longer pointing at Maria, | 1,549 | 2.79 |
I have literally orphaned
the entirety of this list. | 1,551.79 | 3.01 |
I have leaked 1, 2, 3, 4,
5, 6, 7 chunks of memory, | 1,554.8 | 4.1 |
seven nodes, because I got my
order of operations out of order. | 1,558.9 | 3.78 |
Indeed, I should have done
what-- let's undo, control Z. | 1,562.68 | 3.69 |
And now let me go ahead and do what? | 1,566.37 | 1.82 |
Jordan should point at the exact
same thing Scully is pointing at, | 1,568.19 | 3.8 |
which has no downside. | 1,571.99 | 1.53 |
Even though it feels redundant,
we've not lost any information. | 1,573.52 | 2.68 |
And now that Jordan
is pointing at Maria, | 1,576.2 | 2.83 |
Scully's pointer can
be pointed at Jordan. | 1,579.03 | 2.935 |
And now, even though the
list looks a little weird, | 1,581.965 | 2.125 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.