VIDEO: With which we can solve problems and we revisit.
DOUG LLOYD: We've covered a lot of different data structures.
Or we're starting to cover a lot of different structures at this point.
And the one that students are most familiar with at this point is arrays.
But arrays, they're great to get started with.
But they definitely suffer from a few major flaws.
And particularly the fact that they're fixed
size and can only hold elements of one type.
At least in a language like C.
DAVID MALAN: Indeed.
And you have to know, of course, a priori, how big of an array you want.
Otherwise you have to manually re-allocate it and repopulate it
or copy everything over.
So this is actually one of our first, one of many, but one of our best,
I think, opportunities in class to really start
discussing deeply trade offs.
DOUG LLOYD: Right
DAVID MALAN: And having students critically
think about what an array is good for.
What it's bad for.
And what kind of ceiling you bump up against ultimately
with this data structure when it comes to solving more sophisticated problems.
The goal here is, without just saying, hey,
there's these other data structures in the world like linked lists, trees,
or whatnot.
What are the problem with what we have, so as to actually motivate
solving the problem.
DOUG LLOYD: Right.
Yeah.
I would say that, at least in my opinion,
week five is really the week where we start to focus a lot more on design.
Or encouraging students to think a little more critically about design.
DAVID MALAN: And it's an opportunity to really start
to use as building blocks, pointers, and a basic understanding of memory
management.
To start to stitch together our own things in memory.
And this is actually one of the reasons that I like C so much.
Is that we have this ability, albeit at a low level, which
can be a little scary and a little difficult to grok at first.
But we have this ability to create out of memory anything we want.
And so only those data structures we ourselves
design and then implement do we have at our disposal.
DOUG LLOYD: Right.
It's something that students can take for granted
later on when they use a language like PHP or Python.
The things like hash tables are just given to them for free
by virtue of using that language.
Here they get to see what it's like behind the scenes at the very
low level.
Which really only C, among languages that are frequently used today,
that gives us the chance to really take that peak.
DAVID MALAN: And it allows us to continue the conversation too
about abstraction.
In that, with an array, we can ultimately build other things.
Even using that data structure eventually
we'll talk about stacks, and queues.
Which could be implemented more dynamically with linked lists.
But they could also be implemented with fairly fixed sizes using an array.
And yet you can therefore abstract away the inside of a stack or a queue,
might indeed be an array.
But there too, it's an opportunity to understand
what the limitations or implications of that design decision are.
Especially if it's the easier of the two design decisions.
As soon as you take out your text editor and have
to start stitching things together with pointers,
there's a bit more effort involved.