Placeholder Image

Subtitles section Play video

  • I think I made a mistake.

  • When I first got here as a freshman some years ago, I immediately grabbed, uh, gravitated toward things familiar to me, right?

  • Like I knew in high school that I was I liked history.

  • I really like my constitutional law class.

  • And so when I sat down with my proctor, my resident advisor, that first week, those first weeks of school and was thinking about what courses should I take and what should I concentrate in or major in?

  • I really stuck with those things that I already knew.

  • And so I signed up is ah, government concentrator ago of Major and I spent the next year and 1/2 of my life taking government classes and related fields and statistics and math and so forth.

  • And yet, when I was in high school, I still had this curiosity about other fields, and I rather postponed in my mind once I became a freshman.

  • All all studies some dramatic arts later on some, uh, some Latin later on, even then, some archaeology later on, a kind of kept thinking I'll get to my electives.

  • But first I'm gonna focus on just getting done.

  • What I think I should get done.

  • And it was completely to the exclusion of computer science as well.

  • In fact, I was always a bit of a geek, but I never had taken any CS courses in high school.

  • I still remember kind of peering through the door of our computer science lab and wondering like what my you are.

  • So I thought geek, your friends were actually doing with their heads, hunker down and typing away on some keyboard.

  • And to me, it was just c++ or job over these these names that I had heard but didn't really know what they are.

  • And indeed, that was what was true.

  • I didn't really know what this other field Waas and I didn't take this class CS 50 my freshman year because I was frankly scared of it.

  • It had and still has to some extent, this reputation to beware because it's so unfamiliar to so many students myself included.

  • And it wasn't until my sophomore year that I finally got up the nerve to sign up for CS 50 after shopping it for one week.

  • But even then, the only reason I got my foot in the door was because the professor at the time let me sign up for the course pass fail because I think the crux of it for this field and a few others was that I feared failure not doing well in a world that was completely new to me.

  • I assume that every other kid in the class, it's surely been programming since here she was like, 12 years old.

  • And reality was that's actually not the case.

  • Even today's over almost 70%.

  • 70% of the students and CS 50 were actually just like me and have never studied computer science before.

  • But eventually I figured out, and that first semester I figured out exactly what it was that this field was.

  • It wasn't about Java or C plus plus or even about programming.

  • It was really about problem solving and thinking more carefully, more methodically about problems and how you can divide and conquer problems in the real world, sometimes with the help of a computer.

  • But frankly, you don't even need the help of a computer to solve these kinds of problems.

  • Really.

  • You just need a an algorithmic way of thinking, amore, methodical way of thinking.

  • So what might this mean?

  • So while the bus these days have these kinds of devices in our pocket and when you actually use it for old school purposes, like making a phone call, you might open up your contacts and maybe, ah, little inefficiently scroll through the list of friends and family, starting with the A's all the way down to disease.

  • Or maybe a little more cleverly, you might do auto complete and start searching.

  • But how does that work?

  • It's actually not all that different from our approach and yesteryear toe looking up people we know in this device, right?

  • There's a whole bunch of names alphabetically in this, and they have corresponding numbers.

  • And that's exactly the same thing that's going on in your iPhone or Android phone or the like.

  • So let's consider how the phone these days actually finds the friend or family member you want to call quite quickly in using.

  • This is the metaphor, really the derivative of what that wrote the origin of what that device is so I could open up this phone book.

  • I'm looking for someone like my friend Mike Smith and look down at the first page.

  • See that he's clearly not on it because Smith starts with s.

  • And so I just keep turning the pages one at a time, looking for Mike.

  • Now, obviously, this is pretty slow, and it's gonna take me forever to find him.

  • But that's okay.

  • I had sort of I knew algorithms from when I was growing up.

  • I don't have to do things one at a time.

  • I could do them two at a time.

  • So, uh, 2468 And this, too is gonna take a lot longer.

  • But of course, no one in this room is going to do that.

  • And our iPhones and android devices don't do that.

  • What would you do instinctively if you had a book that's even this big to find?

  • Someone like Mike Smith?

  • Yes, a split roughly in the middle.

  • And, of course, I'm gonna end up in roughly, like the M section, give or take.

  • And Mike's not in the M section.

  • Could Smith again starts with s, but what do I know about Mike Smith?

  • Where is he In this book now?

  • Yeah, he's kind of over there to the right, because s comes after the middle of the phone book.

  • And so both physically and metaphorically can I divide and tear this problem in half, leaving just half of the phone?

  • But don't worry, I don't actually need this phone book anymore.

  • So leaving just half of the phone book.

  • But what can I do next?

  • I can really just repeat that process.

  • Now, of course, maybe I've gone a little too far this time and I mean the T section, not the SS.

  • But that's okay, because I can against terror.

  • The problem in half, leaving me now with maybe not 1000 pages or 500.

  • Maybe I'm already down to, like, 250 pages.

  • And just look at the progress I'm making through the phone book rather than one page at a time or two pages of the time, but apparently hundreds of pages at a time.

  • And if I can continue this divide and conquer, or if we call it by its fancier named binary search by meaning to, and we keep dividing in half, hence the two do we eventually end up hopefully with one page on which Mike Smith actually is now what does this mean to be more efficient?

  • It clearly is faster than just looking through every page or every other page off the phone book.

  • But if we just think about fundamentally what we just did, this isn't even relate to computers.

  • It just relates to thinking were carefully about a problem.

  • If we think about I saw that souvenir to go.

  • Uh, if we just think about what we just did well, let's just consider very generic, not mathematically oriented.

  • It all chart where this is like the size of the problem I care about.

  • And by size I mean, like numbers of pages in the phone book.

  • It's okay.

  • You can keep it the number of pages in the phone book and let's just call the vertical axis here time.

  • And what's the relationship among these three algorithms we just tried?

  • Well, the first algorithm was just one page at a time, and every page might take me one second or half a second or whatever.

  • So it's a very straight or linear relationship.

  • More pages or time or pages more time.

  • Meanwhile, if I do two pages at a time, it's still the same linear relationship.

  • I'm just going twice as fast, so the shape of that curve is the same shape, but it's lower because if I consider this many pages in the first algorithm, it took me this money steps.

  • But in the second algorithm takes me half a cz many steps because we're going to two at a time.

  • But what's the shape of that third and final and, frankly, much more intuitive algorithm that all of us have been taking for granted all these years?

  • Even if we've never studied computer science or programming or program, it turns out it's much doesn't get negative.

  • It turns out it's much more curved like this that happens to be called log arrhythmic.

  • But the point is that in order for this third algorithm to take Maur time, you really have to keep going and going and going and really see how far out it goes before it really makes a fundamental impact on the amount of time it's taking.

  • Put another way, if I double the number of pages in that phone book tomorrow, how many more steps would it take me to find that same person?

  • Mike Smith.

  • Just one more step.

  • So if you double the number of pages, the amount of time required to find Mike Smith really just inches up ever so slightly.

  • It doesn't maintain this same relatively slow approach.

  • Now, we can actually do this in another way.

  • What's another algorithm we might have in a venue like this?

  • We'll kind of be nice to know how many people are here.

  • So I could do it.

  • Old school into 123 45678 Okay, that's gonna take forever.

  • So I know how to do this better.

  • 2468 10 12 14.

  • But saying if we can't learn a little something from this now, I can't quite do this on my own.

  • But what if we just said, you know, we need to leverage everyone here, And in fact, let me let me do this.

  • Let's consider how we might visualize the counting of each other here.

  • I need eight volunteers who didn't know they were gonna be volunteers earlier.

  • Dubai.

  • But all seven of you stand up if you could.

  • And can we steal number eight over here?

  • Come on over.

  • All right.

  • So I'm gonna give each of these students here your very own CS 50 pen.

  • All right, That's so you're it's holding a pen and let's go ahead and do this if we could.

  • 78 If all of you guys want to.

  • Just wrote spin around for the most uncomfortable thing you're gonna do today, but no stew in advance.

  • Well, this is the class of 2022.

  • Welcome to your classmates.

  • And what's your name?

  • Miranda.

  • Andrea, Lindsay, Virginia.

  • Anna, Serena, Multi and Dora.

  • All right, so thank you.

  • All of you for volunteering.

  • So let's count the eight of you now.

  • There's obviously eight.

  • So we know the answer to this.

  • Stay right there, if you could, but how could I go about counting?

  • Just these 81234 or 2468 So that's gonna take me eight steps or or four steps.

  • But can I do it in three?

  • And I count the same groups of the same group of eight students with just three steps.

  • Well, let's consider this.

  • How about this?

  • Could half of you give away your pen to someone l two standing, and then if you gave away your pen, just sit down.

  • So half of you who are standing give away your pen to someone else.

  • And then that same half.

  • Sit down.

  • So now four of you are still standing in.

  • Each of you presumably have 2222 pens.

  • Well, let's repeat this.

  • So half of you give your pens away to someone else still standing, and then sit down.

  • And now there's just two of you and in a moment is gonna be one lucky winner of eight pens.

  • So if the half of you just one of you could give your pens away and then sit down, okay, and then sit down.

  • What's your name again?

  • Lindsay is holding eight pens, has the final tally.

  • But how many times did we do that?

  • We did it 123 times because we went from 8 to 4 to two.

  • And then we were left with just the one person standing with all a pen.

  • So a round of applause, if we could for our volunteers, you should probably give them back to everyone.

  • Yes.

  • So let's end by just considering how we can really do this and mass because it would take me forever to count 2468 So could we actually do this together more intelligently, leveraging that same algorithm, That same step by step approach to solving a problem as follows.

  • If I were to say Alright, this half of the room count yourselves this half of the room.

  • Count yourselves.

  • We could just combine the result just like these volunteers were repeatedly combining their results.

  • So I don't have, unfortunately hundreds of pens on me.

  • But I can give you each a number.

  • So let me just virtually give you each The number one, including our volunteers.

  • Everyone will participate if you could.

  • So everyone, for the moment, think of yourself as the number one.

  • And now this is the awkward part for all of us.

  • If you would humor me and everyone stand up also in place.

  • So everyone at this moment is thinking of the number one.

  • And just as with our volunteers, we're just gonna do one round together.

  • Then we'll pause, reset to make sure we're good to go and then repeat each of you is the thinking of the number one.

  • If you could each verbally give away half of you give away that number to someone else next to you.

  • Okay, so at this point, if you gave away your number.

  • Sit down.

  • Is half of you seem to have done so at this point in the story.

  • Just a quick sanity check.

  • Everyone who's standing should probably be thinking of the number two.

  • Okay, so we're about to repeat this, whereby half of you next need to give away your number, which is now two to someone else.

  • They added together.

  • And that may propose.

  • Repeat until there's one person standing and continue to repeat, give away your number and let someone else take it from there.

  • It's okay.

  • Keep repeating.

  • If you're standing and not talking to someone, try to give your number away.

  • Okay, take another moment.

  • Give your number away to someone else if you can, and then sit down.

  • All right, I'll help out if need be.

  • If it's a little too awkward to shout your number, I hear someone's offering 15.

  • If someone wants the 15 16 all right, let me facilitate at this point, just cause it might be getting a little awkward.

  • So whoever still standing, I brought my calculator just so I don't screw up my own arithmetic.

  • Her what number you thinking of you are 32 so go ahead and sit down.

  • You are thinking you are 37.

  • Go ahead and sit down.

  • You're 44.

  • Go ahead and sit down.

  • Who's still standing?

  • 64.

  • Go ahead and sit down.

  • Who's still standing there?

  • 67.

  • Go ahead and sit down.

  • Who's still standing?

  • 45.

  • Okay, you're said 45.

  • Go ahead and sit down back there.

  • 64.

  • Go ahead and sit down.

  • Over here.

  • 40 eights.

  • Go ahead and sit down back there.

  • Sorry.

  • 24.

  • Go ahead and sit down.

  • Who's still staying?

  • One more.

  • 31 in 81.

  • Both of you can sit down.

  • Is anyone still standing right here in the middle?

  • 36.

  • Go ahead and sit down.

  • Over here.

  • 24.

  • I promise.

  • This algorithms, Fast 24.

  • Go ahead and sit down.

  • Okay.

  • And back there.

  • 16.

  • All right.

  • So that I miss anyone.

  • Did I miss anyone?

  • All right.

  • So let's consider for just a moment what should have just happened on each iteration or cycle of that algorithm.

  • Half of you were sitting down than another half than another half, so we were taking great big bites out of the same problem.

  • Just like we were taking big bites out of the phone book and just as these, they were intuitively having themselves again and again and because each of them gave their pen away on each generation.

  • But we preserve the number of pens just as you as you gave your number one or number two or whatever.

  • It was a way we preserved the total addition.

  • Theoretically, the last person standing, which I guess will be me because I did all the adding here should have the total count of people in this room Now The total I got arithmetically by adding that all up is that there are, according to this algorithm, 613 people in the room.

  • But we did it the old school way during that same algorithm and the number we got earlier waas just over 100 and 50 people.

  • So that so.

  • That's okay, That's okay.

  • This is our first example, perhaps of a bug or mistaking a program.

  • And well, we'll come back to that this fall.

  • But rest assured, even if this was not within your comfort zone or if you've never taken a CS class before, do consider exploring some new unfamiliar field in any of our four fields here and beyond and do a CZ.

  • I wish I had done way back then.

  • Allow me to step off stage, though, and paint a picture in closing off Not only the material in the world that awaits you, but also the community.

  • This particular film that was put together by one of CS 50 zone former students.

  • Emily you, who's behind the camera here, right now.

  • Now on C s fifties production team paints a picture off the world that awaits you.

  • What?

  • Wait.

I think I made a mistake.

Subtitles and vocabulary

Click the word to look it up Click the word to find further inforamtion about it