Placeholder Image

Subtitles section Play video

  • >> [MUSIC PLAYING]

  • >> -Alright!

  • >> -This is CS50.

  • >> -This is CS50.

  • >> -This is CS50.

  • [MUSIC -- IGGY AZALEA, "FANCY"]

  • >> -My favorite memory from CS50 was when I went to Puzzle Day.

  • >> -Probably just the time spent working on problem sets

  • with my friends and people who wold eventually become my blockmates.

  • >> -My best memory from CS50 is the Hackathon.

  • -The CS50 Hackathon.

  • >> -Hackathon.

  • >> -Hackathon.

  • -Hackathon.

  • -The Hackathon

  • -Rob Bowden.

  • Just everything about him.

  • >> [MUSIC -- IGGY AZALEA, "FANCY"]

  • >> -My favorite memory is when I was on stage and I played the prestigious role

  • of a node [? in the Linked ?] [? List. ?]

  • >> -When we all got free Dropbox space and David was like, look under your seats.

  • And it was like, space for everyone!

  • >> [MUSIC -- IGGY AZALEA, "FANCY"]

  • >> -My advice for any incoming student would

  • be to really work on P-sets with friends.

  • >> -Office hours is very much your friend.

  • >> -Make the most of your experience and meet as many people as you can.

  • >> -Don't be afraid to ask for help.

  • -Start the P-sets early in the week.

  • -I think the biggest thing is to take advantage of all the resources

  • that CS50 has.

  • >> -Go to office hours early in the week.

  • >> -Definitely watch the shorts.

  • >> -Don't procrastinate on your P-sets.

  • -Make sure you find a great group of people to work on P-sets with.

  • You can have a lot of fun and get work done together.

  • >> -Don't be afraid to push yourself.

  • Go for the hacker edition sometimes.

  • >> -Write things on paper before you ever touch your computer.

  • >> -CS50 is really great at providing ways to get help.

  • >> -My one piece of advice is sleep.

  • Has anybody said that?

  • Sleep, for sure.

  • It's easy not to do, but you've got to do it, I think.

  • >> -I would say really be mentally prepared because you're going to love it.

  • [MUSIC -- IGGY AZALEA, "FANCY"]

  • >> -This is CS50.

  • >> -This is CS50.

  • >> -This is CS50.

  • [MUSIC -- IGGY AZALEA, "FANCY"]

  • >> -This is CS50.

  • >> [APPLAUSE]

  • >> DAVID J. MALAN: So this is CS50 and this is the end of Week 0.

  • And that was just some of CS50's staff who

  • await you not only in sections and office hours, but,

  • also, this coming weekend at CS50 Puzzle Day.

  • Which, again, is not all about programming.

  • Indeed, it's expected that you won't have to program anything,

  • but rather solve problems using wits and friends alongside you.

  • >> We will be joined by some of our friends at Facebook--

  • if you register here-- who for the past several years,

  • have actually been writing these challenges with us.

  • And so, they will be the ones ultimately running Puzzle Day.

  • And so, you will be challenged with precisely the kinds of things

  • and problems that folks at Facebook like to think about.

  • So that is tomorrow.

  • Register at cs50.harvard.edu/register.

  • >> Now a word on a couple of staff in particular.

  • This here is Ansel Duff, who is actually one

  • of the co-authors of these binary bulbs that we saw on Wednesday,

  • in addition to CS50's own Dan Bradley.

  • Ansel Duff was also a former freshman advisee of mine 3 years ago

  • and he actually even built this lectern.

  • He's gone on to do engineering sciences and more.

  • Now, his picture here is actually Ansel 3 years ago at the CS50 Hackathon

  • when he borrowed one of our balloons, stuck it to his laptop,

  • and, for the next 12 some odd hours, focused on his final project,

  • taking breaks only to open bags of candy at the Hackathon.

  • >> But he went on more recently to spend this past summer with us,

  • since CS50 for its staff, and now students this semester,

  • has its own 3D printer.

  • And in a nutshell a 3D printers is a device that looks quite like this.

  • You fill it with a plastic spool that is melted down by the device

  • and you build things literally from nothing.

  • Much like an inkjet printer, you start spitting out little dots of plastic

  • that form together to form whole objects.

  • And so Ansel for instance, earlier this summer, has an iPhone 5

  • and decided he really wanted to prop it up on his desk.

  • But he didn't want to go out and buy something

  • from the Apple store or the like, so he sat down and started drawing something.

  • He took a few measurements as to how thick

  • and how wide his iPhone was, he drew this image here,

  • he decided that he wanted to have a 75 degree tilt

  • as it was staring at him on his desk there.

  • He then turned this, using software, into a 3D CAD model

  • that looked a little something like this.

  • And then he proceeded, ultimately, to actually create it.

  • So in fact, if any of you here, perhaps in a row that I can throw to, have

  • an-- there we have folks with iPhone 5 , and here we have two more.

  • >> Now, not to be outdone, CS50's own Cheng Gong also set out this summer

  • to build quite a few things and, in fact, for reasons that are still

  • unclear, has been slowly printing an army of elephants

  • with articulating arms and trunks.

  • A couple of which are actually here if anyone would now like-- an elephant.

  • All right, . but what Cheng also did for us is he very kindly set up a camera

  • because that elephant, believe it or not,

  • takes some two and a half hours to print.

  • Even the iPhone stand took an hour and a half to print.

  • And what Cheng went ahead and did was set up a nice camera in front

  • of this 3D printer, filmed for an hour and a half as Ansel's design printed.

  • We overlaid some sexy music to it in order

  • to give you this to look at how 3D printing works.

  • And even though this is actually in plastic,

  • realize that if this is an area of interest to you academically,

  • there are folks, among them Jennifer Lewis here

  • at the School of Engineering, who are actually

  • working on 3D printing of plastic objects.

  • But even, increasingly, biological materials to solve

  • physiological problems for humans.

  • But here is a little something from CS50.

  • >> [LOUD MECHANICAL NOISES]

  • DAVID J. MALAN: It doesn't sound anything like that in reality,

  • but it's much cooler to watch it at that speed, and with that sound.

  • >> Now, on Wednesday, how did we first get here?

  • We started talking about computer science and we asked what it was.

  • And it's about a number of things, and there's so many different directions

  • in which you can head after a course like CS50.

  • In fact, if you picked up one of those unofficial guides

  • to CS outside, the booklet that we've provided, whether you're

  • thinking of taking just CS50, or maybe doing a secondary,

  • or maybe even concentrating in CS, do flip through that.

  • And you'll see a diagram toward the end that

  • shows you the many different directions in CS that you can go off in.

  • >> But for today, we'll focus, again, on really one of the fundamental views,

  • perhaps, where you have inputs to problems,

  • you have outputs from problems, and you have

  • algorithms with which to create those outputs from those inputs.

  • And one such example, was of course, this phone book here.

  • And we used as an example to go through an algorithm that was correct.

  • And then another one was correct, but a little faster.

  • And then another one that was a little more dramatic, but fundamentally

  • faster.

  • >> Right, this phone book we claimed had about 1,000 pages.

  • And how many times did I have to tear the phone book in half

  • to find someone like Mike Smith, maximally, in 1,000 page book?

  • So, 10 give or take.

  • And so once I tore this thing in half, or simply, more maturely,

  • divided in half, it's only 10 pages out of 1,000.

  • And if you extrapolate, a little unrealistically for a phone book,

  • but if this phone book had some 4 billion pages in it, so completely

  • unwieldy physically, how many times do you divide a 4 billion

  • page phone book in half?

  • So it's actually 32, give or take.

  • And so 32 times only, out of 4 billion pages, can

  • you find someone like Mike Smith.

  • And that's efficiency.

  • That's a good algorithm, daresay.

  • >> But then we moved from that to try to formalize it.

  • And I proposed this pseudocode code.

  • Pseudocode code is not anything formal.

  • It's not something you memorize.

  • It's just something you express fairly intuitively using English,

  • or any language really, that conveys your ideas succinctly.

  • But what's key about pseudocode code is that you

  • try to anticipate all of the possible cases that might happen.

  • And indeed, in this pseudocode code, there were really three cases

  • every time I divided the phone book.

  • Mike might be to the left.

  • Mike might be to the right.

  • Or he might be right on the page I'm on.

  • Or a fourth corner case, so to speak.

  • A bad scenario might be one which-- what is happening?

  • Mike's just not in the phone book at all.

  • >> And when programs crash-- when Mac and PC software that you guys run

  • on your computers sometimes hangs or quits unexpectedly,

  • that generally means that some programmer, some human like you soon,

  • just screwed up and made some mistake.

  • Maybe didn't anticipate that maybe there is no Mike Smith in the phone book.

  • And if you don't actually write code to handle situations like that,

  • generally unpredictable things can happen.

  • Your machine can freeze.

  • It can reboot.

  • The program can quit.

  • And so all of these stupidities that you may

  • have encountered in your actual life just using computers,

  • will increasingly be just explained away by this intuition

  • and this understanding of what is actually going on underneath the hood.

  • >> Now let's try to take a look at a more general problem.

  • Rather than take attendance in a place like

  • this, which would be quite slow to do one, two, three, four.

  • Or maybe two, four, six, eight.

  • Let's focus, instead, on how we might formalize

  • the algorithm of the process by which we could take attendance.

  • And along the way, let's start to apply some nomenclature

  • that we'll use today when we actually start programming in a language.

  • So I give you now, a four minute video that we put together with our friends

  • from TED, the organization.

  • Whereby we supplied a script and they brought their animators to bear,

  • and actually created a 2D animation of what an algorithm is.

  • If we could dim the lights.

  • >> [MUSIC PLAYING]

  • NARRATOR: What's an algorithm?

  • In computer science, an algorithm is a set

  • of instructions resolving some problem step-by-step.

  • Typically, algorithms are executed by computers,

  • but we humans have algorithms as well.

  • For instance, how would you go about counting

  • the number of people in a room?

  • Well, if you're like me, you'd probably point at each person one at a time

  • and count up from zero.

  • One, two, three, four, and so forth.

  • Well, that's an algorithm.

  • In fact, let's try to express it a bit more formally in pseudocode code.

  • English-like syntax that resembles a programming language.

  • >> Let n equal 0.

  • For each person in room, set n equal to n plus 1.

  • How to interpret the pseudocode?

  • Well line one declares, so to speak, a variable

  • called n and initializes its value to 0 This just

  • means that at the beginning of our algorithm,

  • the thing with which we're counting has a value of 0.

  • After all, before we start counting we haven't counted anything yet.

  • Calling this variable n is just a convention.

  • I could have called it most anything.

  • Now line two demarks the start of a loop,

  • a sequence of steps that will repeat some number of times.

  • So in our example, the step we're taking is counting people in the room.

  • Beneath line two is line three which describes

  • exactly how we'll go about counting.

  • The indentation implies that it's line three that will repeat.

  • So with the pseudocode code is saying is that after starting at 0

  • for each person in the room we'll increase n by 1

  • Now is this algorithm correct?

  • Well let's bang on it a bit.

  • >> Does it work if there are two people in the room?

  • Let's see.

  • In line one we initialize n to 0.

  • For each of these two people, we then increment n by 1.

  • So in the first trip through the loop, we update n from 0 to 1.

  • On the second trip through that same loop, we update n from 1 to 2.

  • And so, by this algorithm's end, n is 2, which

  • indeed matches the number of people in the room.

  • So far, so good.

  • >> How about a corner case though?

  • Suppose that there are 0 people in the room-- besides me, who's

  • doing counting.

  • In line one, we again initialize n to 0.

  • This time though, line three doesn't execute at all

  • since there isn't a person in the room.

  • And <