Beruflich Dokumente
Kultur Dokumente
that we've set up in this course over the past many years
has been for exactly that reason-- to provide an on ramp that still exits
just as rigorously and just as high as ever-but the slope of which allow students less comfortable and more comfortable
alike to succeed irrespective of his or her prior background.
>> Indeed, what ultimately matters in this class is not
so much where you end up relative to your classmates
but where you in week 12 end up relative to yourself
in week zero, which is where we are here today.
>> Indeed and this may very well and probably does look like Greek
to many of you.
But rest assured, that this and so much more
is going to be completely within your grasp in just a little bit of time.
>> But today, we focus on some of the higher level ideas
to give you a taste of CS50 and computer science
in a sense of what you're signing up for.
And indeed, computer science might be distilled more
simply as computational thinking-- thinking like a computer, if you will.
And there's so many different things ingredients that go into that,
but let's propose just three for today.
If the goal of the class ultimately is not to teach you programming,
is not to teach you C or PHP or SQL or any number of the words
and acronyms in the course's description,
but rather to teach you to solve problems more effectively
and to think more methodically and more algorithmically, so to speak.
Let's see what exactly this means.
>> So I would propose that thinking computationally boils down
to solving problems.
What do you need to solve a problem?
You need to input-- like the input to the problem-you need an output, which is hopefully the solution,
and then you need a process by which to solve that problem, which
we'll call an algorithm-- a set of instructions for solving some problem.
>> But first, let's focus on the first and the last of these inputs and outputs.
Computers after all, apparently only understands zeros and ones.
But how can that possibly be?
Even if you're not familiar at all with what's underneath the hood,
you probably at least heard that computers understand binary-just zeros and ones-- but how can you possibly do anything interesting?
>> Well, one of the themes of the class is going
to be this layering-- where today, we'll take a quick glance at the lowest level
details, but with each passing day, where we layer
or abstract on top of those details to actually solve higher level
problems of interest to us.
>> So here is what we might call binary-- with just an alphabet of 0 and 1.
But we humans are mostly familiar with decimal.
Dec meaning 10.
Bi meaning two.
And so in the decimal system, we have 10 digits
at our disposal-- of course, zero through nine.
So if you look at a number like this, most of you
intuitively just grasp that is 123.
There's nothing really hard about that.
But why is it 123?
Well, if you think back to grade school-- or at least
the way I learned this kind of world-- you
might recall that we treated these things in columns, or places.
>> So we have the ones place on the right.
The tens place in the middle.
The hundreds place on the left.
And then how do we get from this pattern symbols-1 2 3-- to this higher level idea that we know as 123?
Well, it's just some simple arithmetic.
Right?
>> The one there is essentially means give us 100 times 1 plus 10 times
2 plus 1 times 3.
And of course if we do out the math there, it's 100 plus 20
plus 3-- otherwise known as 123.
>> So if you're on the same page as that right
now and are comfortable with the so-called decimal system as a human,
it's actually well within your scope of comfort
to consider now the binary system.
Take a wild guess-- this represents, in the world of computers
in binary-- what number?
Zero.
>> But why is that?
Well, it turns out that the columns or places here-- they're not powers of 10.
1, 10, 100, 1,000, and so forth.
They're instead, quite simply, powers of 2.
So, 1, 2, 4, 8, 16, 32, and so on.
And so now we of course get to 0 here simply because we have 4 times
0 plus 2 times 0 plus 1 times 0, which of course gives us 0.
>> But how do I go about representing the number 1?
What's the pattern of zeros and ones to represent
the number we humans know as 1?
001.
And 2?
010.
>> And now the pattern starts to repeats.
Now it's 011.
And again, 0 fours, one 2, one 1.
So 2 plus 1.
That's 3.
>> And now to represent 4, we don't just change that 0 to a 1.
You sort of have to carry, so to speak, and the numbers
start flipping around just like in the decimal world.
>> So this is 4.
This is 5.
This is 6.
This is 7.
And so we've counted as high as 7.
>> Now all we just need is more a bits-- more zero's and one's.
And indeed "bits", if you've heard this term-- binary digit.
Bit is where that comes from.
And so if we want to represent bigger numbers, we need more bits.
But let's move away from slides now to something a little more real.
Suppose that we want to actually represent this thing.
>> Well let's take a look now at a little demonstration.
So this is a web based application that one of CS50's own, Michael G,
put together this summer to help us elucidate exactly this idea.
And would someone like to venture up on stage
in front of all his or her classmates?
Right there in front.
Come on up.
>> You have to be comfortable on camera and the internet.
Oh, right here.
OK.
We're OK.
All right.
Come on up.
H-I and then an exclamation point, which was not actually on the screen.
But indeed there's a mapping for every letter to every number
that you might want to type on your keyboard.
>> But numbers don't have to represent just letters.
Right?
All of us know about images and photographs and audio files
and video files and the like.
So clearly we can represent higher level things still.
And so what a computer does is simply choose
to interpret patterns of zero ones differently based on the context.
>> If you double click a Microsoft Word icon,
you see words on the screen instead of colors and pictures
because word knows that this is an essay that you've actually typed.
If you instead double click on a JPEG or a GIF or a PNG,
it opens up and is an image because the .PNG or the .docx or whatever the file
extension is and whatever software you're using knows to interpret
a pattern of zeros and ones differently based on what its purpose in life is.
>> So for instance, this same sequence of numbers
might represent how much red do you want, how much green do you want,
and how much blue do you want.
And indeed, if you've ever heard RGB-- so just red green blue.
And so if I see numbers like, this give me 72 red, give me 73 green,
and 33 blue, this is how a computer using three bytes-- where
a byte is eight bits or 24 bits-- would represent a pretty nasty shade
of brown or yellow here.
And in different contexts, could those exact same patterns in zeros and ones
mean something completely different as well.
>> So we have now a way of representing information-- zeros and ones.
On top of that, we get letters.
On top of that, we might get colors.
And let's assume for today that we can get audio and video
and things so much more sophisticated than that.
>> But now let's consider how we use those inputs
and produce those outputs now that we have
a way of representing that information.
Well, we need something called an algorithm.
Again, a set of instructions for solving some problem
step by step-- and the more precise, the better.
>> And so an example with which humans are admittedly less familiar these days,
but nonetheless is still with us in software,
is the process of looking up someone in a phone book.
>> Now, fewer and fewer folks know each year what this relic actually is here.
But back in my day, this was a phone book
with thousands of pages and numbers and people's names from A through Z.
And even though we're kind of cheating a bit-- this is mostly yellow pages.
There were also white pages at the time, which
had all of those names and numbers of actual human beings.
>> And if I wanted to look someone up in a phone book like this today, of course
,
I just type in the first few characters of his or her name,
and my phone finds that information.
But the process by which your iPhone or Android phone
or whatever is actually finding someone in your contacts list
is identical to what we humans probably have done for some time.
>> Now I could take this problem, if you will,
and the inputs here are not zeros and ones.
They're pages-- like, let's say 1,000 pages.
And if I wanted to look up someone like Mike Smith in this phone book,
I could start at the beginning and see that I'm in the A section
and then turn one page at a time, looking and looking
as I make to the B's and the C's and the D's and so forth for Mike Smith.
Smith starting with an S, I'll hopefully eventually find him.
>> Is this algorithm-- that process-- correct?
Yeah.
It's correct.
I will find Mike if he's in here, but what's the caveat that you might offer.
It's slow.
Right?
I know Mike S is sort of toward the latter half of the phone book.
Why the heck am I starting at the beginning
and going page by page by page.
So of course, I could flip it around and start from the back,
but that's going to get me there at the same rate,
if you willl-- page after page after page.
And it's not going to work if I want to search for someone else whose
name comes earlier in the alphabet.
>> So what if I do what I learned in grade school,
again, do things not by ones but by twos.
So 2, 4, 6, 8, 10, 12, and so forth.
Is that correct?
No.
It's kind of correct.
But some of you who murmured no, where is the problem, or the bug,
the mistake so to speak.
Yeah.
>> STUDENT: You might skip over the right entry.
>> DAVID MALAN: Yeah.
I might skip over Mike Smith is because I've taken two pages at once
and he just happens to be sandwiched between those two pages.
I might realize that I'm on to the T section
not having found Mike Smith yet.
>> And so what might the fixed there be?
Well, if I do hit the Ts in the phone book,
I might need to double back one or so page.
So it's fixable, but it's not quite as simple
as just going by two to speed up my performance.
But what?
Come on.
What is what most humans are going to do with this kind of phone book?
You're given the phone book.
What do you do?
>> What's that?
Go to the middle.
So I heard go to the middle, and I find myself roughly in the M section,
so to speak.
And now what do I want to do?
Good job.
What's your name?
>> JAMES: James.
>> DAVID MALAN: James, all right.
What do I do next?
JAMES: You go in the half that has the S's.
DAVID MALAN: All right.
I'm going to go into the half that has the S's in it because, again,
a stipulation here was that this thing is sorted.
It's a pretty useless 1,000 pages if Verizon doesn't actually
sort these things for us A through Z.
So if I know Mike is probably in the latter half of the phone book,
I can now.
>> [LAUGHS]