1 00:00:00,000 --> 00:00:02,952 >> [MUSIC PLAYING] 2 00:00:02,952 --> 00:00:11,316 3 00:00:11,316 --> 00:00:13,284 >> [MUSIC PLAYING] 4 00:00:13,284 --> 00:00:18,722 5 00:00:18,722 --> 00:00:19,680 DAVID MALAN: All right. 6 00:00:19,680 --> 00:00:21,983 This is CS50. 7 00:00:21,983 --> 00:00:24,108 [MUSIC PLAYING Tritonal, Cash Cash, "Untouchable"] 8 00:00:24,108 --> 00:01:40,846 9 00:01:40,846 --> 00:01:41,844 [MUSIC PLAYING] 10 00:01:41,844 --> 00:01:45,337 SPEAKER 1: I'm going to France, and you're going, too. 11 00:01:45,337 --> 00:01:48,331 [MUSIC PLAYING] 12 00:01:48,331 --> 00:02:38,100 13 00:02:38,100 --> 00:02:41,930 DAVID MALAN: This is CS50, Harvard University's introduction 14 00:02:41,930 --> 00:02:44,520 to the intellectual enterprises of computer science 15 00:02:44,520 --> 00:02:47,940 and the arts of program-- and for the first time in history, 16 00:02:47,940 --> 00:02:49,800 Yale University's as well. 17 00:02:49,800 --> 00:02:53,830 Indeed, whether you're here in Cambridge or in New Haven or Miami or St. Louis 18 00:02:53,830 --> 00:02:55,550 or Amsterdam or anywhere around the world 19 00:02:55,550 --> 00:03:00,080 taking CS50, computer science E50, CS50X, CS50 AP, 20 00:03:00,080 --> 00:03:02,090 we are all one and the same. 21 00:03:02,090 --> 00:03:04,490 Welcome to CS50. 22 00:03:04,490 --> 00:03:05,380 >> What we have-- 23 00:03:05,380 --> 00:03:06,348 >> [APPLAUSE] 24 00:03:06,348 --> 00:03:07,800 >> [LAUGHS] 25 00:03:07,800 --> 00:03:10,220 >> [APPLAUSE] 26 00:03:10,220 --> 00:03:13,610 27 00:03:13,610 --> 00:03:16,920 >> So I made a mistake myself some time ago when I started off college. 28 00:03:16,920 --> 00:03:21,580 And I got to college, and I decided to frankly, stick within my comfort zone. 29 00:03:21,580 --> 00:03:24,475 I ended up declaring a concentration, or a major, of government. 30 00:03:24,475 --> 00:03:27,880 Ant that was mostly a function of me being pretty familiar with government 31 00:03:27,880 --> 00:03:31,270 or at least history or I really liked constitutional law in high school. 32 00:03:31,270 --> 00:03:34,150 And so when I got here, I kind of gravitated toward things 33 00:03:34,150 --> 00:03:35,800 with which I was already familiar. 34 00:03:35,800 --> 00:03:36,300 Right? 35 00:03:36,300 --> 00:03:38,167 God forbid I do poorly in the class. 36 00:03:38,167 --> 00:03:40,250 I certainly wanted to stay within my comfort zone, 37 00:03:40,250 --> 00:03:43,010 and it wasn't until sophomore year that I finally 38 00:03:43,010 --> 00:03:46,820 got up the nerve to step foot in a classroom called CS50. 39 00:03:46,820 --> 00:03:51,150 And at that point, did I finally realize that, my God, homework could actually 40 00:03:51,150 --> 00:03:51,910 be fun. 41 00:03:51,910 --> 00:03:54,410 >> Indeed, I was one of those kids that on Friday evenings when 42 00:03:54,410 --> 00:03:57,640 the P-SETS would be released, I would go back to my room and dive 43 00:03:57,640 --> 00:03:58,790 into the night's P-SETS. 44 00:03:58,790 --> 00:04:01,606 And for me, that was a sign that this was a field for me. 45 00:04:01,606 --> 00:04:04,480 But what was more important was the fact that I did get up this nerve 46 00:04:04,480 --> 00:04:08,000 to explore waters unfamiliar to me and get beyond my own comfort zone 47 00:04:08,000 --> 00:04:12,320 and frankly, I only was able to do that sophomore year by taking this class 48 00:04:12,320 --> 00:04:13,050 pass/fail. 49 00:04:13,050 --> 00:04:16,470 >> Indeed, it was the very last day that I finally switched over and finally 50 00:04:16,470 --> 00:04:19,707 declared CS as my concentration, putting gov at that point behind me. 51 00:04:19,707 --> 00:04:22,290 And so we're not setting out in this course to turn all of you 52 00:04:22,290 --> 00:04:25,780 into CS majors or concentrators, but rather to give you an opportunity 53 00:04:25,780 --> 00:04:29,780 to hopefully go beyond the world with which you're currently familiar 54 00:04:29,780 --> 00:04:33,660 and bring back from this world skills and knowledge and savvy 55 00:04:33,660 --> 00:04:36,220 that you can apply to your own world, whether that's 56 00:04:36,220 --> 00:04:39,080 in the humanities, social sciences, natural sciences, or beyond. 57 00:04:39,080 --> 00:04:40,871 >> Indeed, if you're feeling a little intrepid 58 00:04:40,871 --> 00:04:43,250 about being in this room let alone in this class, 59 00:04:43,250 --> 00:04:47,560 realize that if history is any indication, 72% of you 60 00:04:47,560 --> 00:04:49,802 have never taken a CS course before. 61 00:04:49,802 --> 00:04:52,760 So it is by all means not the case that the student sitting to the left 62 00:04:52,760 --> 00:04:56,850 or to the right or in front or behind you knows far more about CS 63 00:04:56,850 --> 00:04:58,820 or programming in particular than you. 64 00:04:58,820 --> 00:05:00,432 That's not in fact the case. 65 00:05:00,432 --> 00:05:02,140 And indeed, much of the support structure 66 00:05:02,140 --> 00:05:04,600 that we've set up in this course over the past many years 67 00:05:04,600 --> 00:05:08,840 has been for exactly that reason-- to provide an on ramp that still exits 68 00:05:08,840 --> 00:05:11,640 just as rigorously and just as high as ever-- 69 00:05:11,640 --> 00:05:14,860 but the slope of which allow students less comfortable and more comfortable 70 00:05:14,860 --> 00:05:18,420 alike to succeed irrespective of his or her prior background. 71 00:05:18,420 --> 00:05:20,610 >> Indeed, what ultimately matters in this class is not 72 00:05:20,610 --> 00:05:22,830 so much where you end up relative to your classmates 73 00:05:22,830 --> 00:05:26,000 but where you in week 12 end up relative to yourself 74 00:05:26,000 --> 00:05:28,720 in week zero, which is where we are here today. 75 00:05:28,720 --> 00:05:32,315 >> Indeed and this may very well and probably does look like Greek 76 00:05:32,315 --> 00:05:32,940 to many of you. 77 00:05:32,940 --> 00:05:35,200 But rest assured, that this and so much more 78 00:05:35,200 --> 00:05:38,990 is going to be completely within your grasp in just a little bit of time. 79 00:05:38,990 --> 00:05:41,410 >> But today, we focus on some of the higher level ideas 80 00:05:41,410 --> 00:05:43,822 to give you a taste of CS50 and computer science 81 00:05:43,822 --> 00:05:45,530 in a sense of what you're signing up for. 82 00:05:45,530 --> 00:05:48,000 And indeed, computer science might be distilled more 83 00:05:48,000 --> 00:05:51,209 simply as computational thinking-- thinking like a computer, if you will. 84 00:05:51,209 --> 00:05:54,000 And there's so many different things ingredients that go into that, 85 00:05:54,000 --> 00:05:56,240 but let's propose just three for today. 86 00:05:56,240 --> 00:05:59,420 If the goal of the class ultimately is not to teach you programming, 87 00:05:59,420 --> 00:06:03,022 is not to teach you C or PHP or SQL or any number of the words 88 00:06:03,022 --> 00:06:04,730 and acronyms in the course's description, 89 00:06:04,730 --> 00:06:07,850 but rather to teach you to solve problems more effectively 90 00:06:07,850 --> 00:06:11,670 and to think more methodically and more algorithmically, so to speak. 91 00:06:11,670 --> 00:06:13,610 Let's see what exactly this means. 92 00:06:13,610 --> 00:06:17,000 >> So I would propose that thinking computationally boils down 93 00:06:17,000 --> 00:06:17,834 to solving problems. 94 00:06:17,834 --> 00:06:19,333 What do you need to solve a problem? 95 00:06:19,333 --> 00:06:21,470 You need to input-- like the input to the problem-- 96 00:06:21,470 --> 00:06:23,636 you need an output, which is hopefully the solution, 97 00:06:23,636 --> 00:06:26,720 and then you need a process by which to solve that problem, which 98 00:06:26,720 --> 00:06:30,030 we'll call an algorithm-- a set of instructions for solving some problem. 99 00:06:30,030 --> 00:06:33,340 >> But first, let's focus on the first and the last of these inputs and outputs. 100 00:06:33,340 --> 00:06:38,070 Computers after all, apparently only understands zeros and ones. 101 00:06:38,070 --> 00:06:39,299 But how can that possibly be? 102 00:06:39,299 --> 00:06:42,090 Even if you're not familiar at all with what's underneath the hood, 103 00:06:42,090 --> 00:06:44,980 you probably at least heard that computers understand binary-- 104 00:06:44,980 --> 00:06:48,050 just zeros and ones-- but how can you possibly do anything interesting? 105 00:06:48,050 --> 00:06:49,960 >> Well, one of the themes of the class is going 106 00:06:49,960 --> 00:06:53,293 to be this layering-- where today, we'll take a quick glance at the lowest level 107 00:06:53,293 --> 00:06:55,620 details, but with each passing day, where we layer 108 00:06:55,620 --> 00:06:59,420 or abstract on top of those details to actually solve higher level 109 00:06:59,420 --> 00:07:01,080 problems of interest to us. 110 00:07:01,080 --> 00:07:04,730 >> So here is what we might call binary-- with just an alphabet of 0 and 1. 111 00:07:04,730 --> 00:07:06,960 But we humans are mostly familiar with decimal. 112 00:07:06,960 --> 00:07:08,130 Dec meaning 10. 113 00:07:08,130 --> 00:07:09,070 Bi meaning two. 114 00:07:09,070 --> 00:07:12,100 And so in the decimal system, we have 10 digits 115 00:07:12,100 --> 00:07:14,099 at our disposal-- of course, zero through nine. 116 00:07:14,099 --> 00:07:16,140 So if you look at a number like this, most of you 117 00:07:16,140 --> 00:07:19,016 intuitively just grasp that is 123. 118 00:07:19,016 --> 00:07:20,640 There's nothing really hard about that. 119 00:07:20,640 --> 00:07:22,452 But why is it 123? 120 00:07:22,452 --> 00:07:24,660 Well, if you think back to grade school-- or at least 121 00:07:24,660 --> 00:07:26,410 the way I learned this kind of world-- you 122 00:07:26,410 --> 00:07:29,640 might recall that we treated these things in columns, or places. 123 00:07:29,640 --> 00:07:31,412 >> So we have the ones place on the right. 124 00:07:31,412 --> 00:07:32,620 The tens place in the middle. 125 00:07:32,620 --> 00:07:34,240 The hundreds place on the left. 126 00:07:34,240 --> 00:07:36,980 And then how do we get from this pattern symbols-- 127 00:07:36,980 --> 00:07:41,771 1 2 3-- to this higher level idea that we know as 123? 128 00:07:41,771 --> 00:07:43,461 Well, it's just some simple arithmetic. 129 00:07:43,461 --> 00:07:43,960 Right? 130 00:07:43,960 --> 00:07:48,960 >> The one there is essentially means give us 100 times 1 plus 10 times 131 00:07:48,960 --> 00:07:50,410 2 plus 1 times 3. 132 00:07:50,410 --> 00:07:53,430 And of course if we do out the math there, it's 100 plus 20 133 00:07:53,430 --> 00:07:56,480 plus 3-- otherwise known as 123. 134 00:07:56,480 --> 00:07:58,820 >> So if you're on the same page as that right 135 00:07:58,820 --> 00:08:02,320 now and are comfortable with the so-called decimal system as a human, 136 00:08:02,320 --> 00:08:05,750 it's actually well within your scope of comfort 137 00:08:05,750 --> 00:08:07,220 to consider now the binary system. 138 00:08:07,220 --> 00:08:10,110 Take a wild guess-- this represents, in the world of computers 139 00:08:10,110 --> 00:08:12,001 in binary-- what number? 140 00:08:12,001 --> 00:08:12,500 Zero. 141 00:08:12,500 --> 00:08:13,580 >> But why is that? 142 00:08:13,580 --> 00:08:17,460 Well, it turns out that the columns or places here-- they're not powers of 10. 143 00:08:17,460 --> 00:08:19,670 1, 10, 100, 1,000, and so forth. 144 00:08:19,670 --> 00:08:21,890 They're instead, quite simply, powers of 2. 145 00:08:21,890 --> 00:08:25,400 So, 1, 2, 4, 8, 16, 32, and so on. 146 00:08:25,400 --> 00:08:29,630 And so now we of course get to 0 here simply because we have 4 times 147 00:08:29,630 --> 00:08:34,510 0 plus 2 times 0 plus 1 times 0, which of course gives us 0. 148 00:08:34,510 --> 00:08:37,399 >> But how do I go about representing the number 1? 149 00:08:37,399 --> 00:08:39,440 What's the pattern of zeros and ones to represent 150 00:08:39,440 --> 00:08:42,720 the number we humans know as 1? 151 00:08:42,720 --> 00:08:44,280 001. 152 00:08:44,280 --> 00:08:46,370 And 2? 153 00:08:46,370 --> 00:08:47,480 010. 154 00:08:47,480 --> 00:08:49,760 >> And now the pattern starts to repeats. 155 00:08:49,760 --> 00:08:50,890 Now it's 011. 156 00:08:50,890 --> 00:08:54,310 And again, 0 fours, one 2, one 1. 157 00:08:54,310 --> 00:08:55,180 So 2 plus 1. 158 00:08:55,180 --> 00:08:56,140 That's 3. 159 00:08:56,140 --> 00:08:59,069 >> And now to represent 4, we don't just change that 0 to a 1. 160 00:08:59,069 --> 00:09:01,360 You sort of have to carry, so to speak, and the numbers 161 00:09:01,360 --> 00:09:03,700 start flipping around just like in the decimal world. 162 00:09:03,700 --> 00:09:04,670 >> So this is 4. 163 00:09:04,670 --> 00:09:05,410 This is 5. 164 00:09:05,410 --> 00:09:06,330 This is 6. 165 00:09:06,330 --> 00:09:07,580 This is 7. 166 00:09:07,580 --> 00:09:09,720 And so we've counted as high as 7. 167 00:09:09,720 --> 00:09:12,400 >> Now all we just need is more a bits-- more zero's and one's. 168 00:09:12,400 --> 00:09:15,700 And indeed "bits", if you've heard this term-- binary digit. 169 00:09:15,700 --> 00:09:17,470 Bit is where that comes from. 170 00:09:17,470 --> 00:09:20,190 And so if we want to represent bigger numbers, we need more bits. 171 00:09:20,190 --> 00:09:24,360 But let's move away from slides now to something a little more real. 172 00:09:24,360 --> 00:09:27,540 Suppose that we want to actually represent this thing. 173 00:09:27,540 --> 00:09:31,790 >> Well let's take a look now at a little demonstration. 174 00:09:31,790 --> 00:09:35,270 So this is a web based application that one of CS50's own, Michael G, 175 00:09:35,270 --> 00:09:38,160 put together this summer to help us elucidate exactly this idea. 176 00:09:38,160 --> 00:09:40,420 And would someone like to venture up on stage 177 00:09:40,420 --> 00:09:42,915 in front of all his or her classmates? 178 00:09:42,915 --> 00:09:43,790 Right there in front. 179 00:09:43,790 --> 00:09:45,660 Come on up. 180 00:09:45,660 --> 00:09:48,350 >> You have to be comfortable on camera and the internet. 181 00:09:48,350 --> 00:09:50,930 182 00:09:50,930 --> 00:09:52,450 Oh, right here. 183 00:09:52,450 --> 00:09:52,950 OK. 184 00:09:52,950 --> 00:09:53,740 We're OK. 185 00:09:53,740 --> 00:09:54,240 All right. 186 00:09:54,240 --> 00:09:54,740 Come on up. 187 00:09:54,740 --> 00:09:56,150 What's your name? 188 00:09:56,150 --> 00:09:58,550 Emily come on up. 189 00:09:58,550 --> 00:09:59,410 So this is Emily. 190 00:09:59,410 --> 00:10:00,840 What year are you? 191 00:10:00,840 --> 00:10:01,660 >> Freshman. 192 00:10:01,660 --> 00:10:02,810 >> Emily, nice to meet you. 193 00:10:02,810 --> 00:10:03,310 David. 194 00:10:03,310 --> 00:10:03,810 >> All right. 195 00:10:03,810 --> 00:10:06,120 So up on the screen here, we have this touch screen 196 00:10:06,120 --> 00:10:08,425 which is going to allow us to actually interact with this program, 197 00:10:08,425 --> 00:10:09,265 and it's just a browser. 198 00:10:09,265 --> 00:10:11,390 It's Chrome full screened at the moment, but it's 199 00:10:11,390 --> 00:10:14,030 been programmed by Michael to respond in a way that allows 200 00:10:14,030 --> 00:10:15,970 us to play around with binary digits. 201 00:10:15,970 --> 00:10:20,220 >> So for instance, here we have not three but eight bits-- zeros and ones. 202 00:10:20,220 --> 00:10:22,000 Right now, we're looking at the number 0. 203 00:10:22,000 --> 00:10:25,150 And indeed, all eight zeros in decimal means zero. 204 00:10:25,150 --> 00:10:26,900 So that's all that's being hinted at here. 205 00:10:26,900 --> 00:10:29,395 >> So if you wanted to represent the number 8, 206 00:10:29,395 --> 00:10:31,520 what's the pattern of zeros and ones that you want? 207 00:10:31,520 --> 00:10:35,160 You can simply tap up or down or the numbers themselves. 208 00:10:35,160 --> 00:10:35,660 All right. 209 00:10:35,660 --> 00:10:37,659 So that of course is 8, as you can see up there. 210 00:10:37,659 --> 00:10:41,260 And if we wanted to do 16, what do we do? 211 00:10:41,260 --> 00:10:42,701 >> Yep, just touch it again. 212 00:10:42,701 --> 00:10:43,200 16. 213 00:10:43,200 --> 00:10:43,870 All right. 214 00:10:43,870 --> 00:10:46,522 So this is all fine and good, it's still very low level. 215 00:10:46,522 --> 00:10:48,230 We need a way in the real world for Emily 216 00:10:48,230 --> 00:10:50,550 of actually representing these things. 217 00:10:50,550 --> 00:10:54,230 And so suppose that we turn these zeros and ones, which is very 218 00:10:54,230 --> 00:10:55,980 conceptual, into actual light bulbs. 219 00:10:55,980 --> 00:10:56,480 Right? 220 00:10:56,480 --> 00:10:59,540 >> A computer is a physical, mechanical, electrical device. 221 00:10:59,540 --> 00:11:02,220 And its input-- at least if you plug it in or charge it-- 222 00:11:02,220 --> 00:11:05,090 is to have battery power and electrons flowing in and out. 223 00:11:05,090 --> 00:11:08,150 >> So now, why don't we stop thinking about bits as zeros and ones, 224 00:11:08,150 --> 00:11:10,470 but something more physical like light bulbs here. 225 00:11:10,470 --> 00:11:13,815 And if Dan Armendariz could join me for just a moment-- come on up-- 226 00:11:13,815 --> 00:11:15,440 we're going to queue up an application. 227 00:11:15,440 --> 00:11:15,940 >> Come on over, Emily. 228 00:11:15,940 --> 00:11:18,270 Sorry this is the most awkward demo for you ever. 229 00:11:18,270 --> 00:11:20,330 Come on over here. 230 00:11:20,330 --> 00:11:22,080 We're going to queue up with thanks to Dan 231 00:11:22,080 --> 00:11:25,300 Armendariz, another member of our staff, an application known as binary bulb. 232 00:11:25,300 --> 00:11:28,070 >> So what we have here is an iPad application 233 00:11:28,070 --> 00:11:31,970 that has the following user interface on the screen for Emily. 234 00:11:31,970 --> 00:11:35,400 It's just got the same exact UI essentially that's over there. 235 00:11:35,400 --> 00:11:39,220 And if you now want to represent the number, say 8, 236 00:11:39,220 --> 00:11:42,094 how would you go about doing this noticing at the right, 237 00:11:42,094 --> 00:11:43,510 the light bulbs that we have here? 238 00:11:43,510 --> 00:11:46,576 239 00:11:46,576 --> 00:11:47,620 Ah-ha. 240 00:11:47,620 --> 00:11:48,290 Magical. 241 00:11:48,290 --> 00:11:51,830 So if we want to now turn this into something a little more challenging, 242 00:11:51,830 --> 00:11:58,100 and let's go ahead and pick a random number like the number 50 here. 243 00:11:58,100 --> 00:11:59,015 Input this. 244 00:11:59,015 --> 00:12:01,640 And if you can now be challenged to come up with the number 50, 245 00:12:01,640 --> 00:12:04,268 we'll have a fabulous prize for you. 246 00:12:04,268 --> 00:12:06,144 >> EMILY: OK. 247 00:12:06,144 --> 00:12:08,692 Oh my God. 248 00:12:08,692 --> 00:12:10,650 DAVID MALAN: Arithmetic is indeed hard in front 249 00:12:10,650 --> 00:12:12,860 of hundreds of your classmates. 250 00:12:12,860 --> 00:12:16,260 But 50 has been the answer here. 251 00:12:16,260 --> 00:12:18,132 >> [APPLAUSE] 252 00:12:18,132 --> 00:12:21,875 >> And so now, this is meant to be demonstrative for Emily. 253 00:12:21,875 --> 00:12:24,315 So, in here, is some light bulbs quite like these, 254 00:12:24,315 --> 00:12:26,190 but it's actually the little magnetic strips. 255 00:12:26,190 --> 00:12:28,570 And what's cool about these and the reason we use them in CS50 256 00:12:28,570 --> 00:12:31,640 is that they support something called an API-- an application programming 257 00:12:31,640 --> 00:12:34,681 interface, which is just a fancy way of saying that what one of our staff 258 00:12:34,681 --> 00:12:37,284 did over the summer was create an iPad application here 259 00:12:37,284 --> 00:12:39,700 that talks over the internet to the light bulbs over here, 260 00:12:39,700 --> 00:12:41,810 which are wirelessly connected to another device. 261 00:12:41,810 --> 00:12:43,912 But this is now an option for final projects. 262 00:12:43,912 --> 00:12:46,370 And so Emily, if you would so like, at the end of the term, 263 00:12:46,370 --> 00:12:48,703 you can adorn your dorm room in the meantime with those. 264 00:12:48,703 --> 00:12:50,376 Thank you to Emily as well. 265 00:12:50,376 --> 00:12:53,244 >> [APPLAUSE] 266 00:12:53,244 --> 00:12:56,590 267 00:12:56,590 --> 00:13:00,055 >> But now, let's turn our attention to what 268 00:13:00,055 --> 00:13:03,180 that message might have looked like, and it's a little something like this. 269 00:13:03,180 --> 00:13:05,320 In fact, this is an example just as a teaser 270 00:13:05,320 --> 00:13:08,400 of what's to come of what's called an API request. 271 00:13:08,400 --> 00:13:11,409 And so what we have here is simply exactly the kinds of message 272 00:13:11,409 --> 00:13:13,200 that after a few weeks time in CS50, you'll 273 00:13:13,200 --> 00:13:16,590 be able to send to something fairly familiar like that to actually 274 00:13:16,590 --> 00:13:18,100 turn them on and off. 275 00:13:18,100 --> 00:13:19,350 But this is all fine and good. 276 00:13:19,350 --> 00:13:19,850 Right? 277 00:13:19,850 --> 00:13:22,710 We have the mental model hopefully for representing numbers with 278 00:13:22,710 --> 00:13:23,660 zero's and one's. 279 00:13:23,660 --> 00:13:26,290 And from zeros and ones, we can get to higher numbers like 50, 280 00:13:26,290 --> 00:13:29,460 as Emily just did, or we can move up from that. 281 00:13:29,460 --> 00:13:32,160 And I claim that we can represent things like letters as well. 282 00:13:32,160 --> 00:13:32,660 Right? 283 00:13:32,660 --> 00:13:35,360 >> Computers are far more interesting than just numbers. 284 00:13:35,360 --> 00:13:37,340 And so how do you go about representing words 285 00:13:37,340 --> 00:13:39,420 on the screen or emails or essays or the like? 286 00:13:39,420 --> 00:13:43,170 Well, it turns out that computers simply abstract on top of these low level 287 00:13:43,170 --> 00:13:47,380 details, and humans some time ago, came up with an arbitrary, but a consistent, 288 00:13:47,380 --> 00:13:51,710 mapping of numbers to letters-- so that any time you see a capital letter 289 00:13:51,710 --> 00:13:54,170 A on your computer screen, odds are what's 290 00:13:54,170 --> 00:13:57,370 underneath the hood is a pattern of zeros and ones 291 00:13:57,370 --> 00:14:00,650 that represent the number, per this chart, 65. 292 00:14:00,650 --> 00:14:02,830 >> And more physically inside of your computer, 293 00:14:02,830 --> 00:14:06,450 are millions of things called transistors-- these days-- which 294 00:14:06,450 --> 00:14:10,190 are just switches if you will, things that can go on and off and so imagine. 295 00:14:10,190 --> 00:14:14,130 Not eight of these large light bulbs but millions of these tiny little light 296 00:14:14,130 --> 00:14:17,490 bulbs, or switches or transistors, that can turn on and off 297 00:14:17,490 --> 00:14:19,170 based on how you program them. 298 00:14:19,170 --> 00:14:22,120 And so now we have a way of representing letters as well. 299 00:14:22,120 --> 00:14:25,300 >> In fact, if I were to use this mapping here and try to actually 300 00:14:25,300 --> 00:14:28,731 spell something out, we might look at this pattern of decimal digits 301 00:14:28,731 --> 00:14:29,230 right now. 302 00:14:29,230 --> 00:14:31,354 So we're not going to even focus on binary anymore. 303 00:14:31,354 --> 00:14:35,910 Let's just consider these as decimal number 72, 73, 33. 304 00:14:35,910 --> 00:14:38,044 But what might this represent? 305 00:14:38,044 --> 00:14:39,960 Anyone have a sufficiently photographic memory 306 00:14:39,960 --> 00:14:43,060 to know what's spelled on the screen here? 307 00:14:43,060 --> 00:14:43,560 Yeah a few. 308 00:14:43,560 --> 00:14:44,190 So hi. 309 00:14:44,190 --> 00:14:48,330 H-I and then an exclamation point, which was not actually on the screen. 310 00:14:48,330 --> 00:14:51,060 But indeed there's a mapping for every letter to every number 311 00:14:51,060 --> 00:14:53,340 that you might want to type on your keyboard. 312 00:14:53,340 --> 00:14:55,430 >> But numbers don't have to represent just letters. 313 00:14:55,430 --> 00:14:55,930 Right? 314 00:14:55,930 --> 00:14:59,570 All of us know about images and photographs and audio files 315 00:14:59,570 --> 00:15:00,870 and video files and the like. 316 00:15:00,870 --> 00:15:03,580 So clearly we can represent higher level things still. 317 00:15:03,580 --> 00:15:06,920 And so what a computer does is simply choose 318 00:15:06,920 --> 00:15:11,240 to interpret patterns of zero ones differently based on the context. 319 00:15:11,240 --> 00:15:13,130 >> If you double click a Microsoft Word icon, 320 00:15:13,130 --> 00:15:15,900 you see words on the screen instead of colors and pictures 321 00:15:15,900 --> 00:15:18,850 because word knows that this is an essay that you've actually typed. 322 00:15:18,850 --> 00:15:21,510 If you instead double click on a JPEG or a GIF or a PNG, 323 00:15:21,510 --> 00:15:27,070 it opens up and is an image because the .PNG or the .docx or whatever the file 324 00:15:27,070 --> 00:15:30,450 extension is and whatever software you're using knows to interpret 325 00:15:30,450 --> 00:15:34,420 a pattern of zeros and ones differently based on what its purpose in life is. 326 00:15:34,420 --> 00:15:37,330 >> So for instance, this same sequence of numbers 327 00:15:37,330 --> 00:15:41,250 might represent how much red do you want, how much green do you want, 328 00:15:41,250 --> 00:15:42,810 and how much blue do you want. 329 00:15:42,810 --> 00:15:47,490 And indeed, if you've ever heard RGB-- so just red green blue. 330 00:15:47,490 --> 00:15:51,380 And so if I see numbers like, this give me 72 red, give me 73 green, 331 00:15:51,380 --> 00:15:56,910 and 33 blue, this is how a computer using three bytes-- where 332 00:15:56,910 --> 00:16:01,470 a byte is eight bits or 24 bits-- would represent a pretty nasty shade 333 00:16:01,470 --> 00:16:03,660 of brown or yellow here. 334 00:16:03,660 --> 00:16:07,500 And in different contexts, could those exact same patterns in zeros and ones 335 00:16:07,500 --> 00:16:10,780 mean something completely different as well. 336 00:16:10,780 --> 00:16:13,899 >> So we have now a way of representing information-- zeros and ones. 337 00:16:13,899 --> 00:16:15,190 On top of that, we get letters. 338 00:16:15,190 --> 00:16:16,860 On top of that, we might get colors. 339 00:16:16,860 --> 00:16:19,730 And let's assume for today that we can get audio and video 340 00:16:19,730 --> 00:16:22,590 and things so much more sophisticated than that. 341 00:16:22,590 --> 00:16:25,370 >> But now let's consider how we use those inputs 342 00:16:25,370 --> 00:16:27,390 and produce those outputs now that we have 343 00:16:27,390 --> 00:16:29,830 a way of representing that information. 344 00:16:29,830 --> 00:16:31,820 Well, we need something called an algorithm. 345 00:16:31,820 --> 00:16:34,320 Again, a set of instructions for solving some problem 346 00:16:34,320 --> 00:16:37,580 step by step-- and the more precise, the better. 347 00:16:37,580 --> 00:16:42,090 >> And so an example with which humans are admittedly less familiar these days, 348 00:16:42,090 --> 00:16:44,300 but nonetheless is still with us in software, 349 00:16:44,300 --> 00:16:47,490 is the process of looking up someone in a phone book. 350 00:16:47,490 --> 00:16:51,690 >> Now, fewer and fewer folks know each year what this relic actually is here. 351 00:16:51,690 --> 00:16:53,470 But back in my day, this was a phone book 352 00:16:53,470 --> 00:16:57,266 with thousands of pages and numbers and people's names from A through Z. 353 00:16:57,266 --> 00:17:00,390 And even though we're kind of cheating a bit-- this is mostly yellow pages. 354 00:17:00,390 --> 00:17:01,920 There were also white pages at the time, which 355 00:17:01,920 --> 00:17:04,720 had all of those names and numbers of actual human beings. 356 00:17:04,720 --> 00:17:07,970 >> And if I wanted to look someone up in a phone book like this today, of course, 357 00:17:07,970 --> 00:17:11,010 I just type in the first few characters of his or her name, 358 00:17:11,010 --> 00:17:13,480 and my phone finds that information. 359 00:17:13,480 --> 00:17:15,970 But the process by which your iPhone or Android phone 360 00:17:15,970 --> 00:17:18,730 or whatever is actually finding someone in your contacts list 361 00:17:18,730 --> 00:17:22,099 is identical to what we humans probably have done for some time. 362 00:17:22,099 --> 00:17:24,260 >> Now I could take this problem, if you will, 363 00:17:24,260 --> 00:17:26,220 and the inputs here are not zeros and ones. 364 00:17:26,220 --> 00:17:28,730 They're pages-- like, let's say 1,000 pages. 365 00:17:28,730 --> 00:17:32,650 And if I wanted to look up someone like Mike Smith in this phone book, 366 00:17:32,650 --> 00:17:35,570 I could start at the beginning and see that I'm in the A section 367 00:17:35,570 --> 00:17:38,300 and then turn one page at a time, looking and looking 368 00:17:38,300 --> 00:17:42,820 as I make to the B's and the C's and the D's and so forth for Mike Smith. 369 00:17:42,820 --> 00:17:46,000 Smith starting with an S, I'll hopefully eventually find him. 370 00:17:46,000 --> 00:17:50,090 >> Is this algorithm-- that process-- correct? 371 00:17:50,090 --> 00:17:50,590 Yeah. 372 00:17:50,590 --> 00:17:51,610 It's correct. 373 00:17:51,610 --> 00:17:57,040 I will find Mike if he's in here, but what's the caveat that you might offer. 374 00:17:57,040 --> 00:17:57,541 It's slow. 375 00:17:57,541 --> 00:17:58,040 Right? 376 00:17:58,040 --> 00:18:00,975 I know Mike S is sort of toward the latter half of the phone book. 377 00:18:00,975 --> 00:18:02,766 Why the heck am I starting at the beginning 378 00:18:02,766 --> 00:18:04,349 and going page by page by page. 379 00:18:04,349 --> 00:18:06,890 So of course, I could flip it around and start from the back, 380 00:18:06,890 --> 00:18:08,973 but that's going to get me there at the same rate, 381 00:18:08,973 --> 00:18:10,930 if you willl-- page after page after page. 382 00:18:10,930 --> 00:18:14,190 And it's not going to work if I want to search for someone else whose 383 00:18:14,190 --> 00:18:15,880 name comes earlier in the alphabet. 384 00:18:15,880 --> 00:18:17,240 >> So what if I do what I learned in grade school, 385 00:18:17,240 --> 00:18:19,205 again, do things not by ones but by twos. 386 00:18:19,205 --> 00:18:23,060 So 2, 4, 6, 8, 10, 12, and so forth. 387 00:18:23,060 --> 00:18:23,740 Is that correct? 388 00:18:23,740 --> 00:18:27,030 389 00:18:27,030 --> 00:18:27,560 No. 390 00:18:27,560 --> 00:18:28,830 It's kind of correct. 391 00:18:28,830 --> 00:18:33,210 But some of you who murmured no, where is the problem, or the bug, 392 00:18:33,210 --> 00:18:34,240 the mistake so to speak. 393 00:18:34,240 --> 00:18:34,580 Yeah. 394 00:18:34,580 --> 00:18:36,570 >> STUDENT: You might skip over the right entry. 395 00:18:36,570 --> 00:18:37,320 >> DAVID MALAN: Yeah. 396 00:18:37,320 --> 00:18:40,340 I might skip over Mike Smith is because I've taken two pages at once 397 00:18:40,340 --> 00:18:43,190 and he just happens to be sandwiched between those two pages. 398 00:18:43,190 --> 00:18:46,500 I might realize that I'm on to the T section 399 00:18:46,500 --> 00:18:48,690 not having found Mike Smith yet. 400 00:18:48,690 --> 00:18:50,820 >> And so what might the fixed there be? 401 00:18:50,820 --> 00:18:52,709 Well, if I do hit the Ts in the phone book, 402 00:18:52,709 --> 00:18:54,500 I might need to double back one or so page. 403 00:18:54,500 --> 00:18:56,830 So it's fixable, but it's not quite as simple 404 00:18:56,830 --> 00:18:59,170 as just going by two to speed up my performance. 405 00:18:59,170 --> 00:18:59,680 But what? 406 00:18:59,680 --> 00:19:00,180 Come on. 407 00:19:00,180 --> 00:19:03,530 What is what most humans are going to do with this kind of phone book? 408 00:19:03,530 --> 00:19:04,696 You're given the phone book. 409 00:19:04,696 --> 00:19:06,280 What do you do? 410 00:19:06,280 --> 00:19:06,922 >> What's that? 411 00:19:06,922 --> 00:19:07,630 Go to the middle. 412 00:19:07,630 --> 00:19:10,620 So I heard go to the middle, and I find myself roughly in the M section, 413 00:19:10,620 --> 00:19:11,120 so to speak. 414 00:19:11,120 --> 00:19:12,670 And now what do I want to do? 415 00:19:12,670 --> 00:19:14,077 Good job. 416 00:19:14,077 --> 00:19:14,785 What's your name? 417 00:19:14,785 --> 00:19:15,350 >> JAMES: James. 418 00:19:15,350 --> 00:19:15,890 >> DAVID MALAN: James, all right. 419 00:19:15,890 --> 00:19:16,829 What do I do next? 420 00:19:16,829 --> 00:19:18,620 JAMES: You go in the half that has the S's. 421 00:19:18,620 --> 00:19:18,740 DAVID MALAN: All right. 422 00:19:18,740 --> 00:19:20,910 I'm going to go into the half that has the S's in it because, again, 423 00:19:20,910 --> 00:19:22,920 a stipulation here was that this thing is sorted. 424 00:19:22,920 --> 00:19:25,461 It's a pretty useless 1,000 pages if Verizon doesn't actually 425 00:19:25,461 --> 00:19:27,339 sort these things for us A through Z. 426 00:19:27,339 --> 00:19:30,130 So if I know Mike is probably in the latter half of the phone book, 427 00:19:30,130 --> 00:19:31,536 I can now. 428 00:19:31,536 --> 00:19:33,388 >> [LAUGHS] 429 00:19:33,388 --> 00:19:35,240 430 00:19:35,240 --> 00:19:37,391 >> Tear the problem in half. 431 00:19:37,391 --> 00:19:38,615 >> [APPLAUSE] 432 00:19:38,615 --> 00:19:39,115 433 00:19:39,115 --> 00:19:40,300 Thank you. 434 00:19:40,300 --> 00:19:42,510 Tear the problem in half. 435 00:19:42,510 --> 00:19:44,440 That was actually real-- that struggle. 436 00:19:44,440 --> 00:19:47,050 So tear the phone book in half, leaving myself 437 00:19:47,050 --> 00:19:48,580 with fundamentally the same problem. 438 00:19:48,580 --> 00:19:50,060 But of course, half as large. 439 00:19:50,060 --> 00:19:52,550 And if I follow James's advice again, and I go here. 440 00:19:52,550 --> 00:19:54,400 I say, oh now I'm in the T section. 441 00:19:54,400 --> 00:19:56,460 >> And so of course, I can tear the phone book 442 00:19:56,460 --> 00:19:59,660 in half one more time, leaving me with a problem that's 443 00:19:59,660 --> 00:20:00,810 now a quarter of the size. 444 00:20:00,810 --> 00:20:05,335 So I've gone from 1,000 to 500 to 250 to 125 and so forth. 445 00:20:05,335 --> 00:20:07,350 It feels like I'm taking bigger bites out 446 00:20:07,350 --> 00:20:10,615 of this problem with each iteration, or each step in it. 447 00:20:10,615 --> 00:20:15,580 >> And indeed, the time I'm going to spend finding Mike Smith in this example 448 00:20:15,580 --> 00:20:18,970 is so much less because eventually I'm going to whittle this pone book down 449 00:20:18,970 --> 00:20:20,192 to just one lone page. 450 00:20:20,192 --> 00:20:23,010 And if Mike is on that page, I'm going to go ahead and give him 451 00:20:23,010 --> 00:20:24,670 a call having found him. 452 00:20:24,670 --> 00:20:27,030 >> But just how much better is that algorithm-- 453 00:20:27,030 --> 00:20:29,690 that dare say intuitive algorithm-- than the ones we 454 00:20:29,690 --> 00:20:34,920 started with which we're very linear-- left to right-- at a pace of 1 or 2x? 455 00:20:34,920 --> 00:20:36,100 >> Well, let's plot this. 456 00:20:36,100 --> 00:20:39,380 We don't have to worry too much about math or numbers in this case here. 457 00:20:39,380 --> 00:20:40,550 We just look at a plot. 458 00:20:40,550 --> 00:20:43,600 So on the x, or horizontal axis, is the size of the problem-- 459 00:20:43,600 --> 00:20:44,700 how many pages are there. 460 00:20:44,700 --> 00:20:46,760 On the y, or the vertical axis, is how much time 461 00:20:46,760 --> 00:20:48,218 is it going to take me to solve it. 462 00:20:48,218 --> 00:20:50,760 And maybe that's how many page turns, how many seconds, 463 00:20:50,760 --> 00:20:52,370 how many-- some unit of measures. 464 00:20:52,370 --> 00:20:57,810 >> And I've drawn a red straight lines here because if each additional page 465 00:20:57,810 --> 00:21:01,740 of the phone book, I require to make one additional step. 466 00:21:01,740 --> 00:21:03,680 So if Verizon adds one more page next year, 467 00:21:03,680 --> 00:21:06,970 I might have to flip one more page to find someone like Mike Smith. 468 00:21:06,970 --> 00:21:11,340 >> Meanwhile, the second algorithm, which I went by twos, is the same shape. 469 00:21:11,340 --> 00:21:15,220 It's still very linear, very left to right, taking equal bytes each time, 470 00:21:15,220 --> 00:21:16,900 but the slope is a little lower. 471 00:21:16,900 --> 00:21:23,590 >> For instance, if the size of the problem were roughly here 472 00:21:23,590 --> 00:21:25,990 and I used my first algorithm, I might end up all the way 473 00:21:25,990 --> 00:21:27,480 at the top of that red line. 474 00:21:27,480 --> 00:21:29,390 But if I instead use to twosies approach, 475 00:21:29,390 --> 00:21:31,480 the yellow line suggests because it's lower, 476 00:21:31,480 --> 00:21:33,790 that it's going to take me less time the solve. 477 00:21:33,790 --> 00:21:37,400 >> But what's the shape of the third algorithm-- again, arguably 478 00:21:37,400 --> 00:21:38,707 the most intuitive algorithm? 479 00:21:38,707 --> 00:21:40,540 Well, it looks a little something like this. 480 00:21:40,540 --> 00:21:43,480 It's curved, or logarithmic, in shape. 481 00:21:43,480 --> 00:21:46,510 And even though it never kind of flattens out, 482 00:21:46,510 --> 00:21:50,770 it asymptotically inches up and up and up but terribly slowly 483 00:21:50,770 --> 00:21:52,129 versus everything else. 484 00:21:52,129 --> 00:21:53,170 And what's the take away? 485 00:21:53,170 --> 00:21:54,215 Well, we call it log n. 486 00:21:54,215 --> 00:21:55,820 But what does that actually mean? 487 00:21:55,820 --> 00:21:58,580 Well if Verizon doubled the number of pages in the phone book 488 00:21:58,580 --> 00:22:00,810 next year from 1,000 to 2,000. 489 00:22:00,810 --> 00:22:04,600 How many more steps is my first algorithm going to take? 490 00:22:04,600 --> 00:22:05,440 >> My first algorithm. 491 00:22:05,440 --> 00:22:06,399 Maybe 1,000 more steps. 492 00:22:06,399 --> 00:22:08,106 If they doubled the phone book, I'm going 493 00:22:08,106 --> 00:22:10,590 to have to flip through another 1,000 pages to find Mike. 494 00:22:10,590 --> 00:22:13,240 Of course, if the second algorithm, maybe 500 because I'm 495 00:22:13,240 --> 00:22:14,610 going twice as fast. 496 00:22:14,610 --> 00:22:18,380 >> But if Verizon doubles the number of pages between this year and next, 497 00:22:18,380 --> 00:22:21,650 with my third algorithm-- the divide and conquer that James proposed, 498 00:22:21,650 --> 00:22:24,450 going in half and half and half-- how many more steps will 499 00:22:24,450 --> 00:22:29,030 it take me next year to have a phone book of a size 2,000? 500 00:22:29,030 --> 00:22:29,670 Just one. 501 00:22:29,670 --> 00:22:34,110 Because with one bite, I can take, out of that problem, half of the pages 502 00:22:34,110 --> 00:22:34,694 away. 503 00:22:34,694 --> 00:22:37,860 And if you think about this a little crazily now-- if the phone book doesn't 504 00:22:37,860 --> 00:22:41,810 have 1,000 or 2000 page, but let's say 4 billion pages-- 505 00:22:41,810 --> 00:22:45,282 it's a big phone book-- how many times or how many steps 506 00:22:45,282 --> 00:22:47,740 is it going to take me to find Mike Smith in the phone book 507 00:22:47,740 --> 00:22:50,489 with 4 billion pages. 508 00:22:50,489 --> 00:22:52,030 You can sort of start to do the math. 509 00:22:52,030 --> 00:22:52,200 All right. 510 00:22:52,200 --> 00:22:53,175 4 billion divided by 2. 511 00:22:53,175 --> 00:22:54,550 So that's 2 billion divided by 1. 512 00:22:54,550 --> 00:22:55,510 That's 1 billion. 513 00:22:55,510 --> 00:22:56,410 Then half a billion. 514 00:22:56,410 --> 00:22:59,940 Then 250-- so you can do this again and again but not that many times before 515 00:22:59,940 --> 00:23:01,020 you get to one page. 516 00:23:01,020 --> 00:23:04,360 >> And indeed, even if the phone book is 4 billion pages long 517 00:23:04,360 --> 00:23:08,340 or the database you're searching is 4 billion records long, 518 00:23:08,340 --> 00:23:12,720 it's going to take you give or take 32 steps only to find Mike Smith. 519 00:23:12,720 --> 00:23:15,990 And if you double the phone book next year from 4 billion to 8 billion, 520 00:23:15,990 --> 00:23:19,010 33 steps instead of just 32. 521 00:23:19,010 --> 00:23:21,100 >> And this is testament to one of the ideas 522 00:23:21,100 --> 00:23:24,100 that we might embrace in computer science more generally, which 523 00:23:24,100 --> 00:23:26,760 is this computational thinking and approaching a problem 524 00:23:26,760 --> 00:23:29,479 frankly using tools from your already familiar tool 525 00:23:29,479 --> 00:23:31,520 kit-- your real world with which you're familiar, 526 00:23:31,520 --> 00:23:34,730 but harnessing those ideas to actually solve problems. 527 00:23:34,730 --> 00:23:37,200 >> But we need to formalize our solutions to these problems. 528 00:23:37,200 --> 00:23:40,200 And so let me introduce for a moment something we might call pseudocode. 529 00:23:40,200 --> 00:23:44,260 Much of the semester, we'll spend using actual code in languages like C and PHP 530 00:23:44,260 --> 00:23:46,570 and JavaScript and SQL and the like. 531 00:23:46,570 --> 00:23:49,000 >> But for now, let's just look at something fairly intuitive 532 00:23:49,000 --> 00:23:49,930 like English. 533 00:23:49,930 --> 00:23:52,490 I might distill that algorithm with which 534 00:23:52,490 --> 00:23:54,650 I found Mike into steps like this. 535 00:23:54,650 --> 00:23:55,760 >> Pick up the phone book 536 00:23:55,760 --> 00:23:57,121 >> Open to middle of phone book 537 00:23:57,121 --> 00:23:57,870 Look at the name's 538 00:23:57,870 --> 00:23:59,290 If Mike is among the name's 539 00:23:59,290 --> 00:24:00,450 Call Mike 540 00:24:00,450 --> 00:24:02,290 Else if Smith is earlier in the book 541 00:24:02,290 --> 00:24:04,540 Open to the middle of the left half of the book 542 00:24:04,540 --> 00:24:06,244 Else go to line 3 543 00:24:06,244 --> 00:24:07,660 Else if Smith is later in the book 544 00:24:07,660 --> 00:24:09,330 Open to the middle of the right half of the book 545 00:24:09,330 --> 00:24:09,996 Go to line three 546 00:24:09,996 --> 00:24:10,720 Else 547 00:24:10,720 --> 00:24:11,500 Give up 548 00:24:11,500 --> 00:24:15,360 And there's a few characteristics now of this that are worth pointing out. 549 00:24:15,360 --> 00:24:18,370 So one, all the lines I've highlighted in yellow 550 00:24:18,370 --> 00:24:21,430 we're going to start calling statements or functions or procedures. 551 00:24:21,430 --> 00:24:24,160 They're just actions do this, and there's not 552 00:24:24,160 --> 00:24:26,400 all that much variability to it. 553 00:24:26,400 --> 00:24:30,850 >> Next step here though, are these conditions-- if, else, else if, else. 554 00:24:30,850 --> 00:24:34,020 And these are called conditions, or branches, and they're decision points. 555 00:24:34,020 --> 00:24:36,780 And they allow us to do something conditionally. 556 00:24:36,780 --> 00:24:39,650 >> And in fact, let's take a quick look at perhaps a familiar face-- 557 00:24:39,650 --> 00:24:43,380 we'll call him Bill-- and exactly what these conditions, 558 00:24:43,380 --> 00:24:45,670 how these might be used. 559 00:24:45,670 --> 00:24:48,230 >> BILL GATES: People make decisions every day. 560 00:24:48,230 --> 00:24:51,800 For example, before you go outside you kind of have an if statement that says, 561 00:24:51,800 --> 00:24:55,650 if it's raining, then I need to get my jacket. 562 00:24:55,650 --> 00:25:00,990 >> And computers are amazing once you decide those kinds of statements 563 00:25:00,990 --> 00:25:06,450 that they can reliably execute those things at unbelievable speed. 564 00:25:06,450 --> 00:25:12,470 And so a computer program really is a little bit of math and some 565 00:25:12,470 --> 00:25:16,890 if statements where the decision gets made. 566 00:25:16,890 --> 00:25:19,432 >> DAVID MALAN: So now let's focus on a few different lines-- 567 00:25:19,432 --> 00:25:21,140 the ones I've highlighted in yellow here. 568 00:25:21,140 --> 00:25:23,890 And it turns out there's different ways of expressing this idea. 569 00:25:23,890 --> 00:25:28,550 But intuitively what our lines 8 and 11 that I've highlighted here telling you 570 00:25:28,550 --> 00:25:29,100 to do? 571 00:25:29,100 --> 00:25:33,081 Yes, go to line 3, but what behavior is that really inducing? 572 00:25:33,081 --> 00:25:35,580 It's some kind of loop or cycle, and you can kind of see it. 573 00:25:35,580 --> 00:25:36,079 Right? 574 00:25:36,079 --> 00:25:39,710 If on line 8, you go back to line 3, and then you hit line 8 again, 575 00:25:39,710 --> 00:25:42,700 you might go back to line 3, back to line 3, back to line 3. 576 00:25:42,700 --> 00:25:44,530 There's this sort of cycle or loop. 577 00:25:44,530 --> 00:25:47,177 And indeed, that's induced in line 11 potentially as well. 578 00:25:47,177 --> 00:25:49,260 And this is a basic programming construct as well. 579 00:25:49,260 --> 00:25:51,593 >> You might not want to just do something with a statement 580 00:25:51,593 --> 00:25:54,280 or do something conditionally with a condition or branch. 581 00:25:54,280 --> 00:25:56,644 You might want to do something cyclically with a loop. 582 00:25:56,644 --> 00:25:59,810 And we'll have someone else with whom you might be familiar-- we'll call him 583 00:25:59,810 --> 00:26:02,996 Mark-- explain this concept here. 584 00:26:02,996 --> 00:26:04,870 MARK ZUCKERBERG: One thing that computers are 585 00:26:04,870 --> 00:26:07,460 really good at is repeating commands. 586 00:26:07,460 --> 00:26:09,510 As a person, you'd get really bored if you 587 00:26:09,510 --> 00:26:12,310 had to do the same thing lots of times in a row, 588 00:26:12,310 --> 00:26:16,230 but a computer can do the same thing millions or even billions of times 589 00:26:16,230 --> 00:26:18,930 and not get bored and be able to carry that out really well. 590 00:26:18,930 --> 00:26:21,240 >> So for example, if I want to wish everyone 591 00:26:21,240 --> 00:26:24,450 on Facebook a happy birthday by sending them an email, 592 00:26:24,450 --> 00:26:27,037 it might take me more than a century to actually write out 593 00:26:27,037 --> 00:26:28,370 all of those emails to everyone. 594 00:26:28,370 --> 00:26:33,500 But with just a few lines of code, I can have a system send an email to everyone 595 00:26:33,500 --> 00:26:35,460 on Facebook wishing them a happy birthday. 596 00:26:35,460 --> 00:26:38,330 >> So that's what loops are and why they're valuable and something 597 00:26:38,330 --> 00:26:40,076 that computers can do very well. 598 00:26:40,076 --> 00:26:43,109 >> DAVID MALAN: Many thanks to our friends at code.org for those two films. 599 00:26:43,109 --> 00:26:46,150 And just last week, you might have seen that Mark Zuckerberg and Facebook 600 00:26:46,150 --> 00:26:47,940 posted this announcement, which is that they just 601 00:26:47,940 --> 00:26:50,398 have passed an important milestone for the first time ever. 602 00:26:50,398 --> 00:26:54,320 1 billion people used Facebook in a single day, specifically last Monday. 603 00:26:54,320 --> 00:26:58,650 One in seven humans on Earth apparently logged into Facebook. 604 00:26:58,650 --> 00:27:03,310 >> Well, this seems a good opportunity to look back on where Facebook began, 605 00:27:03,310 --> 00:27:06,840 and we went through CS50's own archives because it turns out in 2005, 606 00:27:06,840 --> 00:27:10,020 Mark gave a guest lecture in CS50. 607 00:27:10,020 --> 00:27:13,870 You'll see that production values weren't quite the same back then 608 00:27:13,870 --> 00:27:16,110 in terms of the technology available, and you'll also 609 00:27:16,110 --> 00:27:18,310 see that the presence of this guest lecture 610 00:27:18,310 --> 00:27:22,470 didn't necessarily pique the interest of the student body, your predecessors, 611 00:27:22,470 --> 00:27:24,910 as much as it might have just a few years later. 612 00:27:24,910 --> 00:27:27,902 >> So let's take a look at Science Center C. 613 00:27:27,902 --> 00:27:29,389 614 00:27:29,389 --> 00:27:31,014 SPEAKER 2: Please join me, and welcome. 615 00:27:31,014 --> 00:27:33,374 616 00:27:33,374 --> 00:27:36,577 [APPLAUSE] 617 00:27:36,577 --> 00:27:37,410 MARK ZUCKERBERG: Yo. 618 00:27:37,410 --> 00:27:37,900 All right. 619 00:27:37,900 --> 00:27:40,420 Cool this is the first time I've ever have had to hold one of these things. 620 00:27:40,420 --> 00:27:42,336 So I'm just going to attach it really quickly. 621 00:27:42,336 --> 00:27:54,354 622 00:27:54,354 --> 00:27:54,854 All right. 623 00:27:54,854 --> 00:27:57,314 Can you hear it? 624 00:27:57,314 --> 00:27:58,298 Is this good? 625 00:27:58,298 --> 00:28:00,684 Is this amplified at all? 626 00:28:00,684 --> 00:28:01,184 All right. 627 00:28:01,184 --> 00:28:02,040 Sweet. 628 00:28:02,040 --> 00:28:06,860 So, this is like one of the first times I've been to a lecture at Harvard, 629 00:28:06,860 --> 00:28:08,660 but-- 630 00:28:08,660 --> 00:28:12,510 >> DAVID MALAN: So eventually the Science Center did zoom in on the video, 631 00:28:12,510 --> 00:28:15,110 but not before capturing this excerpt where Mark's talking, 632 00:28:15,110 --> 00:28:18,230 which he discussed his roommate, Dustin, who 633 00:28:18,230 --> 00:28:20,885 wanted to lend a hand with this site called the Facebook.com 634 00:28:20,885 --> 00:28:24,540 and realized that Mark is about to mention to programming languages-- 635 00:28:24,540 --> 00:28:27,290 one called Perl, one called PHP-- as he discusses 636 00:28:27,290 --> 00:28:28,840 the origins of Dustin's contribution. 637 00:28:28,840 --> 00:28:31,499 638 00:28:31,499 --> 00:28:33,290 MARK ZUCKERBERG: I started running the site 639 00:28:33,290 --> 00:28:37,770 and launched it at Harvard in February, 2004. 640 00:28:37,770 --> 00:28:39,540 So I guess almost two years ago now. 641 00:28:39,540 --> 00:28:42,322 And within a couple of weeks, a few thousand people had signed up, 642 00:28:42,322 --> 00:28:45,280 and we started getting some emails from people at other colleges asking 643 00:28:45,280 --> 00:28:47,520 for us to launch it at their schools. 644 00:28:47,520 --> 00:28:49,455 >> And I was taking 161 at the time. 645 00:28:49,455 --> 00:28:52,080 So I don't know if you guys know the reputation of that course, 646 00:28:52,080 --> 00:28:54,402 but it was kind of heavy. 647 00:28:54,402 --> 00:28:57,110 It was a really fun course, but it didn't leave me with much time 648 00:28:57,110 --> 00:28:59,260 to do anything else with Facebook. 649 00:28:59,260 --> 00:29:04,309 So my roommate Dustin, who I guess had just finished CS50, was like, hey. 650 00:29:04,309 --> 00:29:05,100 I want to help out. 651 00:29:05,100 --> 00:29:08,760 I want to do the expansion and help you figure out how to do the stuff. 652 00:29:08,760 --> 00:29:10,780 >> So I was like, that's pretty cool, dude. 653 00:29:10,780 --> 00:29:13,130 But you don't really know any PHP or anything like that. 654 00:29:13,130 --> 00:29:16,444 So that weekend he went home, bought the book Perl for Dummies, 655 00:29:16,444 --> 00:29:17,860 came back and was like, all right. 656 00:29:17,860 --> 00:29:18,940 I'm ready to go. 657 00:29:18,940 --> 00:29:23,010 >> I was like, dude, the site's written in PHP not Perl, but that's cool. 658 00:29:23,010 --> 00:29:28,530 >> So he picked up PHP over like a few days because I 659 00:29:28,530 --> 00:29:30,790 promise that if you have a good background in C, 660 00:29:30,790 --> 00:29:32,970 PHP is a very simple thing to pick up. 661 00:29:32,970 --> 00:29:37,480 And he just kind of went to work. 662 00:29:37,480 --> 00:29:40,500 >> Before we take a look now at where the course is going, 663 00:29:40,500 --> 00:29:43,047 allow me to invite just some of SC50's staff up on to stage. 664 00:29:43,047 --> 00:29:44,880 Some of them are shopping their own courses. 665 00:29:44,880 --> 00:29:48,390 But if those TFs and CAs and course heads who are here could come on up 666 00:29:48,390 --> 00:29:50,230 and join me for a quick hello. 667 00:29:50,230 --> 00:29:54,670 >> Allow me to introduce in particular, Hanna, Maria, Daven, and Rob, 668 00:29:54,670 --> 00:29:59,666 CS50's course heads here in Cambridge. 669 00:29:59,666 --> 00:30:02,106 >> [APPLAUSE] 670 00:30:02,106 --> 00:30:07,490 671 00:30:07,490 --> 00:30:11,060 >> DAVID MALAN: Indeed, testament to the support structure that the course has 672 00:30:11,060 --> 00:30:15,660 built out over the past many years, CS50 staff this year numbers nearly 100, 673 00:30:15,660 --> 00:30:17,170 and that's here in Cambridge alone. 674 00:30:17,170 --> 00:30:21,240 Meanwhile, in New Haven, are there some 40 TFs and CAs and staff members there 675 00:30:21,240 --> 00:30:22,800 to run the course as well. 676 00:30:22,800 --> 00:30:26,125 >> Allow us to introduce first, Rob Bowden. 677 00:30:26,125 --> 00:30:26,750 ROB BOWDEN: Hi. 678 00:30:26,750 --> 00:30:27,620 I'm Rob. 679 00:30:27,620 --> 00:30:32,750 This is my sixth year TFing in the course. 680 00:30:32,750 --> 00:30:37,970 So, all the way back in my freshman year, I did not take CS50. 681 00:30:37,970 --> 00:30:40,270 Your freshman fall-- you might be familiar 682 00:30:40,270 --> 00:30:43,270 that you can only take four courses and there are so many courses today. 683 00:30:43,270 --> 00:30:44,450 So I'm like, eh. 684 00:30:44,450 --> 00:30:48,050 I took AP CS my senior year of high school it was horrible. 685 00:30:48,050 --> 00:30:48,900 So, I'm like, eh. 686 00:30:48,900 --> 00:30:50,380 Computer science is not for me. 687 00:30:50,380 --> 00:30:53,000 >> So then it was over the course of my freshman 688 00:30:53,000 --> 00:30:58,960 fall, that I had a friend in CS50, and I think I attended one lecture with her. 689 00:30:58,960 --> 00:31:03,760 It's like, oh, this is kind of better than what I had in high school. 690 00:31:03,760 --> 00:31:06,990 >> And over the course of the year, I had my own problem sets 691 00:31:06,990 --> 00:31:08,750 in the courses I was actually taking. 692 00:31:08,750 --> 00:31:11,870 But I found that whenever I wanted to procrastinate on those, 693 00:31:11,870 --> 00:31:15,111 I would go back to CS50 and look at some of that stuff. 694 00:31:15,111 --> 00:31:15,610 So, yeah. 695 00:31:15,610 --> 00:31:16,140 I'm cool. 696 00:31:16,140 --> 00:31:19,350 I procrastination with coding. 697 00:31:19,350 --> 00:31:22,910 So then it's at the end of the fall that I realize, hey, 698 00:31:22,910 --> 00:31:24,410 computer science is pretty cool. 699 00:31:24,410 --> 00:31:27,730 I end up taking CS51. 700 00:31:27,730 --> 00:31:30,430 In the next semester, I end up taking CS61. 701 00:31:30,430 --> 00:31:32,727 And it all from there, then I end up declaring 702 00:31:32,727 --> 00:31:35,310 computer science, which I had absolutely no intention of doing 703 00:31:35,310 --> 00:31:36,740 when I came into college. 704 00:31:36,740 --> 00:31:39,330 And now I'm here. 705 00:31:39,330 --> 00:31:42,230 So the course is what you make of it. 706 00:31:42,230 --> 00:31:43,463 I hope you enjoy it. 707 00:31:43,463 --> 00:31:44,066 >> [APPLAUSE] 708 00:31:44,066 --> 00:31:45,315 DAVID MALAN: Thank you to Rob. 709 00:31:45,315 --> 00:31:49,020 710 00:31:49,020 --> 00:31:52,180 >> And now Maria, our head course assistant. 711 00:31:52,180 --> 00:31:53,140 >> MARIA: Hey guys. 712 00:31:53,140 --> 00:31:53,880 My name is Maria. 713 00:31:53,880 --> 00:31:56,930 I'm a sophomore in Cabot House, coming from Bulgaria, 714 00:31:56,930 --> 00:31:59,880 and I'm super excited to be part of the staff this year. 715 00:31:59,880 --> 00:32:03,380 I took CS50 as a freshman last year, and I never even 716 00:32:03,380 --> 00:32:04,750 thought about CS beforehand. 717 00:32:04,750 --> 00:32:08,380 So I absolutely love the course, and I hope you all love it as much as I did. 718 00:32:08,380 --> 00:32:09,250 And, yeah. 719 00:32:09,250 --> 00:32:10,868 Welcome to CS50. 720 00:32:10,868 --> 00:32:12,201 DAVID MALAN: Thank you to Maria. 721 00:32:12,201 --> 00:32:13,674 [APPLAUSE] 722 00:32:13,674 --> 00:32:16,129 723 00:32:16,129 --> 00:32:19,580 Now Hanna, our head teaching fellow. 724 00:32:19,580 --> 00:32:20,480 HANNA: Hi, I'm Hanna. 725 00:32:20,480 --> 00:32:22,990 I'm a senior in Cabot studying computer science. 726 00:32:22,990 --> 00:32:28,120 I took CS50 as a freshman and had been TFing-- this'll be my third year. 727 00:32:28,120 --> 00:32:31,000 So I will be happily involved in CS50 for all four years, 728 00:32:31,000 --> 00:32:33,569 and I'm looking forward to working with you all. 729 00:32:33,569 --> 00:32:34,902 DAVID MALAN: Thank you to Hanna. 730 00:32:34,902 --> 00:32:36,870 [APPLAUSE] 731 00:32:36,870 --> 00:32:37,854 732 00:32:37,854 --> 00:32:40,274 And lastly, Daven, our precepter. 733 00:32:40,274 --> 00:32:40,940 DAVEN: Hey guys. 734 00:32:40,940 --> 00:32:42,390 I'm a precept over in computer science here. 735 00:32:42,390 --> 00:32:44,010 This'll be my fourth year teaching. 736 00:32:44,010 --> 00:32:45,261 I also help manage the course. 737 00:32:45,261 --> 00:32:47,801 So I'm sure you'll see me around, especially at office hours. 738 00:32:47,801 --> 00:32:48,970 I'm always at office hours. 739 00:32:48,970 --> 00:32:51,640 So if you see me walking around, definitely come say hi. 740 00:32:51,640 --> 00:32:52,681 I love to meet everybody. 741 00:32:52,681 --> 00:32:55,830 Otherwise, have fun, and I'll see you around. 742 00:32:55,830 --> 00:32:58,210 >> DAVID MALAN: Thank you to Daven as well. 743 00:32:58,210 --> 00:33:01,290 So you'll meet all of these folks before long. 744 00:33:01,290 --> 00:33:03,040 But without further ado, if you guys would 745 00:33:03,040 --> 00:33:05,840 like to resume your seats from earlier. 746 00:33:05,840 --> 00:33:10,940 Allow me to introduce from afar now some of our friends from New Haven, 747 00:33:10,940 --> 00:33:14,690 in particular the course's heads who'll be overseeing CS50 there-- Professor 748 00:33:14,690 --> 00:33:19,550 Brian Scassellati, Jason, and Andi, who just-- so that we didn't tempt fate 749 00:33:19,550 --> 00:33:22,610 with any FaceTime or the like-- have just sent us minutes 750 00:33:22,610 --> 00:33:27,380 ago the following video in which they say hello from lecture hall 751 00:33:27,380 --> 00:33:31,480 at Yale, in which lecture is being streamed right now. 752 00:33:31,480 --> 00:33:34,052 >> So our friends from Yale. 753 00:33:34,052 --> 00:33:35,260 BRIAN SCASSELLATI: Hi, David. 754 00:33:35,260 --> 00:33:36,480 Hi, everyone at Harvard. 755 00:33:36,480 --> 00:33:41,400 We are so excited to be bringing CS50 to Yale this semester. 756 00:33:41,400 --> 00:33:45,250 My name is Brian Scassellati, but everyone just calls me Scas. 757 00:33:45,250 --> 00:33:50,402 And I'm here today to introduce to you the CS50 staff. 758 00:33:50,402 --> 00:33:52,346 >> [CHEERING] 759 00:33:52,346 --> 00:33:55,760 760 00:33:55,760 --> 00:33:59,780 >> And more importantly, I'm here to introduce as well 761 00:33:59,780 --> 00:34:03,690 all of the students at Yale who as of this morning 762 00:34:03,690 --> 00:34:09,289 have made this the most popular course at Yale the CS50 students. 763 00:34:09,289 --> 00:34:12,090 >> [CHEERING] 764 00:34:12,090 --> 00:34:25,850 765 00:34:25,850 --> 00:34:28,310 >> So we're very excited to be seeing you here 766 00:34:28,310 --> 00:34:34,239 on Friday and on Saturday for Puzzle Day and have a great lecture. 767 00:34:34,239 --> 00:34:35,440 Bye. 768 00:34:35,440 --> 00:34:37,360 >> [APPLAUSE] 769 00:34:37,360 --> 00:34:42,170 770 00:34:42,170 --> 00:34:45,497 >> DAVID MALAN: On the screen here is the names of the some of 140 staff 771 00:34:45,497 --> 00:34:48,330 members who await you over the course of the semester-- some of them 772 00:34:48,330 --> 00:34:50,540 here in Cambridge, some of them here in New Haven. 773 00:34:50,540 --> 00:34:52,706 And indeed you'll have an opportunity this Saturday, 774 00:34:52,706 --> 00:34:54,530 as Scas notes, to attend CS50 Puzzle Day. 775 00:34:54,530 --> 00:34:57,780 You might have seen little puzzle pieces slipped under your doorways recently. 776 00:34:57,780 --> 00:35:00,420 We have a few extras here later on when you exist. 777 00:35:00,420 --> 00:35:04,030 If you assemble all four puzzle pieces and merge forces with rooms 778 00:35:04,030 --> 00:35:06,450 nearby yours in your house or dorm, they'll 779 00:35:06,450 --> 00:35:09,690 assemble into a QR code-- or a two dimensional bar code, that 780 00:35:09,690 --> 00:35:12,970 once assembled and scanned with your phone will lead you 781 00:35:12,970 --> 00:35:17,060 to some fabulous prize or-- I suppose you could just photograph this now 782 00:35:17,060 --> 00:35:17,560 as well. 783 00:35:17,560 --> 00:35:22,560 >> But find those puzzle pieces nonetheless in order to win that fabulous prize. 784 00:35:22,560 --> 00:35:25,900 And indeed one of the traditions in SC50-- ah, too slow. 785 00:35:25,900 --> 00:35:29,790 One of the traditions in CS50 is to serve cake after the first lecture. 786 00:35:29,790 --> 00:35:31,620 >> And so indeed, in a few minutes from now, 787 00:35:31,620 --> 00:35:36,040 there will be cake served outside both here and New Haven as well. 788 00:35:36,040 --> 00:35:39,530 >> But first-- we decorated them ourselves. 789 00:35:39,530 --> 00:35:43,360 But first-- and hopefully there'll be enough. 790 00:35:43,360 --> 00:35:44,830 >> But first, a quick look. 791 00:35:44,830 --> 00:35:47,880 So lectures is indeed will be produced mostly here in Cambridge. 792 00:35:47,880 --> 00:35:51,580 But each month, we'll hop down to Yale with CS50's production team and stream 793 00:35:51,580 --> 00:35:53,730 the course in the reverse direction as well so 794 00:35:53,730 --> 00:35:56,840 as to bring these two campuses truly for the first time in history 795 00:35:56,840 --> 00:36:00,450 as close together as possible as one in the same course. 796 00:36:00,450 --> 00:36:04,050 >> In terms of the support structure that's been stood up here in Cambridge as well 797 00:36:04,050 --> 00:36:05,646 as in New Haven, are sections. 798 00:36:05,646 --> 00:36:08,020 Indeed, as some of you may know, we have different tracks 799 00:36:08,020 --> 00:36:10,850 within the course for those less comfortable, more comfortable, 800 00:36:10,850 --> 00:36:14,610 and somewhere in between so that irrespective of your prior background, 801 00:36:14,610 --> 00:36:17,670 can you ultimately succeed in the class. 802 00:36:17,670 --> 00:36:21,320 >> Office hours meanwhile, are an opportunity on Mondays and Tuesdays 803 00:36:21,320 --> 00:36:26,570 and Thursday evenings to work both here and in New Haven on our course's 804 00:36:26,570 --> 00:36:30,370 problem sets with dozens of the course's staff near you. 805 00:36:30,370 --> 00:36:35,380 >> Problem sets meanwhile, are supported by things we call 806 00:36:35,380 --> 00:36:39,140 walkthroughs, which are video based tutorials that truly answering FAQ 807 00:36:39,140 --> 00:36:41,670 of where to begin a week's challenge. 808 00:36:41,670 --> 00:36:44,290 And postmortems walk you through possible solutions 809 00:36:44,290 --> 00:36:46,490 so that the end of the problem set too, you 810 00:36:46,490 --> 00:36:50,820 know exactly what you could have done differently or altogether otherwise. 811 00:36:50,820 --> 00:36:53,895 >> The problem sets themselves come in two editions, a standard edition 812 00:36:53,895 --> 00:36:57,510 that we expect and invite most of the class-- some 90% plus to do-- 813 00:36:57,510 --> 00:37:00,520 and a so-called hacker edition on which every page is emblazoned 814 00:37:00,520 --> 00:37:02,790 hacker edition, hacker edition, hacker edition, 815 00:37:02,790 --> 00:37:07,550 so that you have that karma if you will, for diving 816 00:37:07,550 --> 00:37:10,230 into more advanced versions of the course's problem sets 817 00:37:10,230 --> 00:37:14,970 that cover ostensibly the same material but with a more sophisticated approach 818 00:37:14,970 --> 00:37:19,020 and with additional background sometimes introduced. 819 00:37:19,020 --> 00:37:22,350 >> Meanwhile, are there nine late days that you can apply to the course's problem 820 00:37:22,350 --> 00:37:26,160 sets as well as the lowest score, which we drop at the terms end. 821 00:37:26,160 --> 00:37:26,900 >> But what awaits? 822 00:37:26,900 --> 00:37:29,300 Well, a taste of the problem sets at hand on Friday 823 00:37:29,300 --> 00:37:31,959 and next week where we dabble for just a few days in something 824 00:37:31,959 --> 00:37:35,000 called Scratch, a graphical programming language developed by our friends 825 00:37:35,000 --> 00:37:39,290 at MIT's Media Lab that allows you to program either for the first time 826 00:37:39,290 --> 00:37:43,510 or in a new environment altogether using a drag and drop type environment. 827 00:37:43,510 --> 00:37:45,595 Whereby puzzle pieces only interlock together 828 00:37:45,595 --> 00:37:48,080 if it makes logical sense to do so. 829 00:37:48,080 --> 00:37:50,440 >> Meanwhile in problem set two last year for instance, 830 00:37:50,440 --> 00:37:53,010 did we introduce the class to the world of cryptography, 831 00:37:53,010 --> 00:37:55,370 the art of encrypting or scrambling information. 832 00:37:55,370 --> 00:37:58,940 Indeed, this text here if decrypted, will actually 833 00:37:58,940 --> 00:38:01,277 lead you to some fun destination. 834 00:38:01,277 --> 00:38:03,110 And in the problem set, what we had students 835 00:38:03,110 --> 00:38:06,280 do is implement exactly those kinds of things-- an algorithm, 836 00:38:06,280 --> 00:38:09,530 or set of instructions for scrambling and scrambling information. 837 00:38:09,530 --> 00:38:11,850 >> And in the hacker edition of that same problem set, 838 00:38:11,850 --> 00:38:15,800 did we challenge students to take a encrypted file from a typical computer 839 00:38:15,800 --> 00:38:18,840 system with lots of usernames and encrypted passwords 840 00:38:18,840 --> 00:38:21,400 and to crack those passwords-- actually figure out 841 00:38:21,400 --> 00:38:25,870 what they were without knowing anything a priori about those actual passwords. 842 00:38:25,870 --> 00:38:27,620 Meanwhile, do we transition in the problem 843 00:38:27,620 --> 00:38:29,536 sets to then looking at the world of graphics. 844 00:38:29,536 --> 00:38:32,240 And in fact, you might imagine now that this could perhaps 845 00:38:32,240 --> 00:38:35,200 be the simplest way to represent a black and white image. 846 00:38:35,200 --> 00:38:39,570 >> A white pixel, or square, as at top right there, 847 00:38:39,570 --> 00:38:41,620 might be represented with a 1 and a black square 848 00:38:41,620 --> 00:38:43,490 might be represented with a 0. 849 00:38:43,490 --> 00:38:47,670 And just by using more bits like we proposed earlier with 72 and 73 and 33, 850 00:38:47,670 --> 00:38:49,882 could we represent color pixels as well. 851 00:38:49,882 --> 00:38:51,590 And what we do during this problem set is 852 00:38:51,590 --> 00:38:54,660 generally take a stroll around campus with a digital camera, 853 00:38:54,660 --> 00:38:56,730 take photographs of people, places, and things. 854 00:38:56,730 --> 00:38:59,270 Then somehow every semester, we seem to accidentally 855 00:38:59,270 --> 00:39:02,600 deleted or corrupt the memory card on which all of those photos are, 856 00:39:02,600 --> 00:39:04,610 and so you are challenged to then write software 857 00:39:04,610 --> 00:39:09,650 with which to recover those JPEGs from a copy of our camera's card. 858 00:39:09,650 --> 00:39:13,550 >> Meanwhile, do we hand you later in the term a dictionary of English words 859 00:39:13,550 --> 00:39:16,680 that have 143,000 words, and you need to come up 860 00:39:16,680 --> 00:39:19,240 with a smart way of loading them into memory, 861 00:39:19,240 --> 00:39:22,850 or RAM so to speak, to answer queries of the form: is this a word, 862 00:39:22,850 --> 00:39:25,910 is this a word, implementing the fastest spell checker that you can, 863 00:39:25,910 --> 00:39:28,180 even pinning yourself potentially against classmates 864 00:39:28,180 --> 00:39:30,460 to see which of you uses the least amount of time 865 00:39:30,460 --> 00:39:33,440 when running your code and even the least amount of memory. 866 00:39:33,440 --> 00:39:36,060 >> Later in term do you actually implement your own web server. 867 00:39:36,060 --> 00:39:39,470 So not just a website in a language called HTML and more, 868 00:39:39,470 --> 00:39:43,300 but a web server that actually listens to requests on the internet 869 00:39:43,300 --> 00:39:44,460 and responds to them. 870 00:39:44,460 --> 00:39:47,210 And indeed, this is how we bridge our world of C with which you'll 871 00:39:47,210 --> 00:39:50,550 become familiar next week and PHP and HTML and JavaScript 872 00:39:50,550 --> 00:39:51,820 and CSS and the like. 873 00:39:51,820 --> 00:39:54,820 >> Because one of the first web based project we do later in the term 874 00:39:54,820 --> 00:39:57,516 is historically CS50 Finance. 875 00:39:57,516 --> 00:40:02,580 Etrade.com style a website that allows you to buy and sell stocks virtually 876 00:40:02,580 --> 00:40:08,240 while also writing code to talk to Yahoo Finance getting semi real time stock 877 00:40:08,240 --> 00:40:11,490 quotes in order to update your own portfolio. 878 00:40:11,490 --> 00:40:13,370 >> But lastly of course, is the final project-- 879 00:40:13,370 --> 00:40:16,960 an opportunity to do most anything of interest to you to solve a problem here 880 00:40:16,960 --> 00:40:20,970 or beyond of interest to you that's somehow inspired 881 00:40:20,970 --> 00:40:22,670 by the lessons learned in the class. 882 00:40:22,670 --> 00:40:26,140 >> And the class, as you may know, culminates in so-called CS50 Hackathon 883 00:40:26,140 --> 00:40:29,330 and CS50 Fair and any number of other cultural events 884 00:40:29,330 --> 00:40:31,770 throughout the semester that allow you to engage 885 00:40:31,770 --> 00:40:33,460 with each other and the course's staff. 886 00:40:33,460 --> 00:40:37,170 >> For instance, at Fire and Ice in Sitar this year, well, on Friday afternoons, 887 00:40:37,170 --> 00:40:39,220 we invite some 50 students to lunch, whoever 888 00:40:39,220 --> 00:40:41,190 would like to join us, myself, and the staff, 889 00:40:41,190 --> 00:40:44,840 and our friends from industry and alums to chat about life in the real world 890 00:40:44,840 --> 00:40:46,670 and beyond while enjoying a good lunch. 891 00:40:46,670 --> 00:40:49,050 At the Hackathon will you see such images 892 00:40:49,050 --> 00:40:53,740 as these, including plenty of candy-- and as of 2014 for the first time-- 893 00:40:53,740 --> 00:40:55,096 vegetables. 894 00:40:55,096 --> 00:40:56,960 >> [APPLAUSE] 895 00:40:56,960 --> 00:40:58,358 896 00:40:58,358 --> 00:41:02,710 >> But by 5:00 AM, does the scene usually look a little something like this. 897 00:41:02,710 --> 00:41:05,330 And then just a week or so later, is the CS50 Fair 898 00:41:05,330 --> 00:41:08,270 to which some 2000 plus students and staff and faculty 899 00:41:08,270 --> 00:41:11,910 members from across campus and across campuses this year 900 00:41:11,910 --> 00:41:15,620 come to see and delight in the accomplishments of CS50 students, which 901 00:41:15,620 --> 00:41:16,140 is now you. 902 00:41:16,140 --> 00:41:19,000 >> And indeed, while this year we'll be inviting and busing anyone 903 00:41:19,000 --> 00:41:22,460 at at Yale who would like to come up to Cambridge this Saturday for CS50 Puzzle 904 00:41:22,460 --> 00:41:26,410 Day, and we'll do the exact same thing in December for the CS50 Hackathon 905 00:41:26,410 --> 00:41:30,080 so that Harvard and Yale students alike partake in both of these events. 906 00:41:30,080 --> 00:41:33,630 >> We will also hold CS50 fairs in Cambridge and in New Haven this year 907 00:41:33,630 --> 00:41:36,480 so that students on both campuses and staff and faculty 908 00:41:36,480 --> 00:41:39,260 can see each respective campus's accomplishment. 909 00:41:39,260 --> 00:41:41,540 And those accomplishments will induce such memory 910 00:41:41,540 --> 00:41:45,440 as this and this and ultimately this, in which all of you 911 00:41:45,440 --> 00:41:48,460 exit the class wearing a little something in which you were hopefully 912 00:41:48,460 --> 00:41:52,680 happy or proud to say that I took CS50. 913 00:41:52,680 --> 00:41:55,220 >> But before that and before we serve cake, 914 00:41:55,220 --> 00:41:58,980 we've put together-- thanks to CS50's production team and a certain self 915 00:41:58,980 --> 00:42:03,120 stick, the one occasion that we use such things for-- when we sent it 916 00:42:03,120 --> 00:42:05,380 not only here to Cambridge but also to New Haven 917 00:42:05,380 --> 00:42:08,760 to gather a few hellos from the course's staff and all of the folks 918 00:42:08,760 --> 00:42:12,640 you will meet both here and in New Haven over the following months. 919 00:42:12,640 --> 00:42:15,449 >> Allow me to introduce a few more of CS50's staff. 920 00:42:15,449 --> 00:42:16,990 MARK ZUCKERBERG: Did that make it go? 921 00:42:16,990 --> 00:42:18,266 Oh, it's going. 922 00:42:18,266 --> 00:42:20,910 It's going. 923 00:42:20,910 --> 00:42:21,570 Ooh. 924 00:42:21,570 --> 00:42:23,170 Yarr! 925 00:42:23,170 --> 00:42:25,350 >> [MUSIC PLAYING ANDY GRAMMER, "HONEY, I'M GOOD"] 926 00:42:25,350 --> 00:42:29,672 927 00:42:29,672 --> 00:42:32,152 >> MARY: This is Caitlin. 928 00:42:32,152 --> 00:42:34,515 That's Jay, and I'm Mary. 929 00:42:34,515 --> 00:42:35,140 SATO: Hi, guys. 930 00:42:35,140 --> 00:42:35,640 I'm Sato. 931 00:42:35,640 --> 00:42:36,264 MICHAEL G.: Hi. 932 00:42:36,264 --> 00:42:37,181 My name is Michael, G. 933 00:42:37,181 --> 00:42:38,014 DOUG LLOYD: I'm not. 934 00:42:38,014 --> 00:42:38,540 No. 935 00:42:38,540 --> 00:42:39,310 I'm Doug Lloyd. 936 00:42:39,310 --> 00:42:41,757 I can't believe that I'm holding a selfie stick right now. 937 00:42:41,757 --> 00:42:42,340 SPEAKER 4: Hi. 938 00:42:42,340 --> 00:42:42,560 SPEAKER 5: Hi. 939 00:42:42,560 --> 00:42:43,307 SPEAKER 6: Hello. 940 00:42:43,307 --> 00:42:44,023 SPEAKER 7: Hi. 941 00:42:44,023 --> 00:42:44,648 SPEAKER 8: Hey. 942 00:42:44,648 --> 00:42:46,436 We're hanging out at Yale. 943 00:42:46,436 --> 00:42:48,910 We're really excited for this semester because it's 944 00:42:48,910 --> 00:42:50,840 the first time it's coming to Yale. 945 00:42:50,840 --> 00:42:53,012 It's going to be awesome! 946 00:42:53,012 --> 00:42:55,928 >> [MUSIC PLAYING] 947 00:42:55,928 --> 00:43:02,190 948 00:43:02,190 --> 00:43:04,664 >> JACOB SCHERBA: My name is Jacob Scherba. 949 00:43:04,664 --> 00:43:08,310 I'm excited to teach CS50 because I think 950 00:43:08,310 --> 00:43:11,429 it bring computer science to people in and approachable way. 951 00:43:11,429 --> 00:43:13,220 SPEAKER 9: I'm really excited to teach CS50 952 00:43:13,220 --> 00:43:17,717 because I took the class last year, and it's one of the best classes. 953 00:43:17,717 --> 00:43:18,425 SPEAKER 10: Yeah. 954 00:43:18,425 --> 00:43:20,476 My advice is you should take CS50. 955 00:43:20,476 --> 00:43:23,350 JACOB SCHERBA: I chose CS because I think it's a fun and creative way 956 00:43:23,350 --> 00:43:25,314 to solve problems in an analytical way. 957 00:43:25,314 --> 00:43:28,480 SPEAKER 11: Back when I was a little freshman and afraid of computer science 958 00:43:28,480 --> 00:43:30,229 and afraid of doing engineering and stuff, 959 00:43:30,229 --> 00:43:34,091 it was the first hard class I took, and it was also my favorite class ever. 960 00:43:34,091 --> 00:43:36,090 DOUG LLOYD: This is my ninth year teaching CS50. 961 00:43:36,090 --> 00:43:37,482 That makes me sound so old! 962 00:43:37,482 --> 00:43:38,690 There's always something new. 963 00:43:38,690 --> 00:43:39,550 There's always something exciting. 964 00:43:39,550 --> 00:43:43,077 There's always new challenges faced by new students, and it's fun to help them 965 00:43:43,077 --> 00:43:44,910 and to experience those challenges with them 966 00:43:44,910 --> 00:43:45,925 and help them solve their problems. 967 00:43:45,925 --> 00:43:47,955 >> SPEAKER 12: When I first learned how to do CS, 968 00:43:47,955 --> 00:43:49,413 it was like learning a super power. 969 00:43:49,413 --> 00:43:53,749 And to see that in other students and to help them through that process 970 00:43:53,749 --> 00:43:55,665 is one of the most rewarding things I've ever. 971 00:43:55,665 --> 00:43:58,706 >> SPEAKER 7: I chose CS because in the beginning, I was a math concentrator 972 00:43:58,706 --> 00:44:00,497 and I took CS50 and fell in love with it. 973 00:44:00,497 --> 00:44:02,455 I also felt that with CS, I could build things. 974 00:44:02,455 --> 00:44:04,410 And that, I thought, was a really cool aspect. 975 00:44:04,410 --> 00:44:08,156 >> SPEAKER 13: Some advice for new students is go to office hours 976 00:44:08,156 --> 00:44:09,573 and hang out with the awesome TFs. 977 00:44:09,573 --> 00:44:11,906 SPEAKER 14: Start your P-SETs early, go to office hours, 978 00:44:11,906 --> 00:44:13,457 become frends with your TF. 979 00:44:13,457 --> 00:44:14,165 SPEAKER 15: Yeah. 980 00:44:14,165 --> 00:44:16,164 Everything she said. 981 00:44:16,164 --> 00:44:17,997 SPEAKER 16: Don't be afraid to ask for help. 982 00:44:17,997 --> 00:44:18,980 SPEAKER 17: Yeah. 983 00:44:18,980 --> 00:44:22,052 SPEAKER 18: Start your P-SETs early. 984 00:44:22,052 --> 00:44:23,760 SPEAKER 19: It's a big social experience. 985 00:44:23,760 --> 00:44:25,112 Make a lot of friends this way. 986 00:44:25,112 --> 00:44:26,570 SPEAKER 14: Go to section It's fun. 987 00:44:26,570 --> 00:44:28,050 SPEAKER 11: I mean, go for it. 988 00:44:28,050 --> 00:44:28,770 It's really hard. 989 00:44:28,770 --> 00:44:30,581 You'll get out of it what you put into it, 990 00:44:30,581 --> 00:44:32,580 but it's a really fun class especially if you're 991 00:44:32,580 --> 00:44:35,496 willing to put the time into it, but it helps if you put time into it. 992 00:44:35,496 --> 00:44:38,336 You'll get a lot more out of it later on. 993 00:44:38,336 --> 00:44:38,960 MIKE: I'm Mike. 994 00:44:38,960 --> 00:44:39,882 CAMILLE: I'm Camille. 995 00:44:39,882 --> 00:44:40,590 HANYA: I'm Hanya. 996 00:44:40,590 --> 00:44:41,310 MATT: I'm Matt. 997 00:44:41,310 --> 00:44:42,140 PETER: I am Peter. 998 00:44:42,140 --> 00:44:42,620 PHILLIP: I'm Phillip. 999 00:44:42,620 --> 00:44:43,495 PATRICK: I'm Patrick. 1000 00:44:43,495 --> 00:44:45,234 ROB BOWDEN: I'm Rob Bowden. 1001 00:44:45,234 --> 00:44:47,150 BRIAN SCASSELLATI: My name is Scas, and this-- 1002 00:44:47,150 --> 00:44:49,958 ALL: --is CS50. 1003 00:44:49,958 --> 00:44:50,806 SPEAKER 20: At Yale. 1004 00:44:50,806 --> 00:44:51,639 SPEAKER 21: At Yale. 1005 00:44:51,639 --> 00:44:52,840 [LAUGHING] 1006 00:44:52,840 --> 00:44:54,270 DAVID MALAN: That's it for CS50. 1007 00:44:54,270 --> 00:44:59,000 We will see you from Yale on Friday, Puzzle Day on Saturday. 1008 00:44:59,000 --> 00:45:00,475 Cake is now served. 1009 00:45:00,475 --> 00:45:01,640 This is CS50. 1010 00:45:01,640 --> 00:45:05,314 1011 00:45:05,314 --> 00:45:10,992 >> [MUSIC PLAYING] 1012 00:45:10,992 --> 00:47:00,434