Placeholder Image

Subtitles section Play video

  • ghost.

  • Oh Mama David Milan hablo un poco espanol.

  • But this will be in English, if that's OK as this morning, but so nice to see some familiar faces and some new ones as well.

  • As Jose said, We thought we'd give you an introduction to computer science, the goal of which is to empower youto have more technical conversations, perhaps with those students were taking Jose's class right now or those of you who are first years.

  • You might like to take Jose's class next semester or beyond.

  • Please feel free to join us in CS 50 and in Kai Esso.

  • Computer science is something that's unfamiliar to a lot of people.

  • For instance, what is computer science?

  • Anyone who's not in Jose's class, What is computer science?

  • Gonna have to call?

  • See?

  • No one's put up.

  • Very few people put up their name tags in this one.

  • That's okay.

  • Cares Latin from Attica.

  • Anyone at all?

  • Anyone at all?

  • It's all right.

  • Someone.

  • How about this from Jose's class?

  • What is computer science?

  • Yes, please.

  • It's the way that computers work.

  • OK, computer language.

  • Okay, hero.

  • No, a way to be broken.

  • Okay.

  • Like translate from Arlen.

  • Good I really like that.

  • So it's the study.

  • It's getting computers to do what we want them to do.

  • And more generally it's the study of information and like the processes around information that allow you to actually solve problems.

  • And frankly, this did not.

  • This was not clear to me when I first was able to study computer science way back in high school.

  • Even in last quail a secondary.

  • I did not study computer science because I thought it was only about programming, and it seemed very anti social, and everyone's heads were down in the computer lab, and they seemed very focused only on the keyboard.

  • But really, it wasn't until college when I took a course called CS 50 that I discovered that it really is more generally about problem solving.

  • And what's exciting about computer science is that it's not just useful within the domain of computer science and Purcell analyzing data and information.

  • But it really is something that you can bring back to your own world, whether that's in the physical sciences, natural sciences, arts, humanities, business or the like, because it's really all about teaching you computational thinking.

  • It cleans up your thinking process.

  • It helps you think Maur logically.

  • It helps you express yourself more precisely more correctly.

  • And as such, it just makes you a much better communicator and, ultimately decision maker.

  • And so with that said, Let's start really at the beginning, What does it mean to think?

  • Computational e What means to think methodically more carefully or as well, Seymour Algorithmic Lee, so to speak.

  • And what does it mean to solve a problem?

  • Well, I'd propose that it really is just this.

  • Any problem in the world just has some input, the problem that you want to solve and you want some solutions.

  • So we'll call that the output.

  • And in between, here is some kind of process, some kind of problem solving mechanism that actually gets the job done.

  • But it's pretty fair to say that this is computer science, at least at a very high level.

  • But before we can discuss inputs and outputs, we like a computer.

  • Scientists need to decide how to represent information.

  • After all, at the end of the day, our computers, our phones only have say electricity, so we really all need to agree in advance how we somehow use electricity to represent inputs and outputs.

  • And it's kind of funny that I just counted the two ingredients to this problem.

  • How might we represent information If we're just counting information, the number of people in the room will 12345 Or I could count higher certainly if I used hash marks one, 23456 and so forth.

  • And so that actually that process has a name.

  • It's called Who?

  • Neri notation, You know, implying one.

  • And that's just because you have one single mark or one type of digit of finger via which you can count people.

  • So just a casual, warm up exercise.

  • Because there's a lot of folks who obviously don't know much about computer science.

  • We would call you back home those less comfortable and that's totally fine.

  • That's the largest demographic of students taking CS 50 back home.

  • How high can I count?

  • On one hand, I hear five six.

  • Okay, um, six is not right, but it is not five.

  • It's not five.

  • You're all wrong somehow.

  • Well, why is that?

  • Well, odds are if you like me, you start counting pretty reasonably like 12345 Okay, now we're out of fingers.

  • Unless we start using the secondhand, so five would seem to be the highest.

  • But that's because I didn't really think very hard about this problem and represent the information as efficiently as optimally as I might be able to write.

  • I'm just putting my fingers up or down, but I'm really taking no into it, not intake.

  • I'm not even taking into account the order in which I'm raising or lowering my fingers.

  • What if instead, this still represent zero?

  • I've not counted anyone yet.

  • But what if I do?

  • This is one.

  • And then maybe this is too.

  • And then this is three.

  • And then if we keep counting it slightly offensive in some cultures, this is four.

  • This is then five.

  • This is then six.

  • This is now seven.

  • So even if you didn't quite follow the exact pattern I was doing, it was obviously not as simple as 12345 I was instead kind of per muting them in different ways by raising and lowering them, thereby making a pattern out of them.

  • And so in that case, it actually is significant.

  • If my finger is up or it's down, that is, there's two states my finger could be in.

  • It's not just that there's a hash mark there or not my fingers either up or down proactively.

  • And that's called binary notation by implying, too.

  • And it's because each my fingers can either be down or up.

  • Or we might call this off or on, or zero or one, but more on that in just a moment.

  • So, in other words, I can actually count much higher than five with five fingers.

  • Does anyone know where want to do the math?

  • How high can I count?

  • Yeah, it's 31.

  • It's very painful to count the 31 on your five human fingers because I don't think I can arrange My fingers is quite cleanly enough to do that.

  • But there are indeed 32 total patterns off fingers up and down on just one hand.

  • If I started zero and I go up to all five, there's 32 total.

  • But if this is zero and this is all up, then if I've got 32 possibilities, I can count from 0 to 31 it turns out, but more on that in just a little bit, so that's a lot.

  • And that suggests that with a little bit more thoughts and a little bit more cleverness as to how a computer scientist represents information, you can pack a lot more information into very limited space.

  • So how do we get those from culinary toe binary to computers?

  • Well, at the end of the day, you probably all know or have heard that computer's only understand binary zeroes and ones.

  • So what does that really mean?

  • Well, it turns out that computers, even though they might seem pretty sophisticated, they're pretty dumb devices, right?

  • They only first of all, do what we tell them to dio.

  • And that's the power is Priscilla notes of getting a computer to do something for you.

  • But moreover, they only take one simple input.

  • They take like electricity from the wall, or maybe from your battery.

  • And even if you've not studied electricity, it's, you know, electrons flowing in or out of the device, somehow powering the device.

  • That's the Onley physical input.

  • And so how perfect is it that there's a way to represent information by either putting a finger down or up or off, or on that is two different states because you can represent two states really easily.

  • For instance, my laptop right now is on, and thankfully it has battery.

  • Now it would be potentially off because it's not plugged in on electricity flowing or off.

  • So why is this Germaine?

  • While a computer, it turns out, can represent information just by storing or not storing electricity?

  • And that's powerful because you can somehow use electricity either on our offer, on or off and represent.

  • It turns out different numbers, but what are those numbers going to be?

  • Well, consider this even if you've never Well, let me ask a question first.

  • How many of you can speak binary or understand binary, right?

  • Priscilla and few other people.

  • OK, so most people not.

  • But it turns out, give me like, two minutes and everyone in this room will be able to Why?

  • Well, first, let's start where we all started as kids.

  • If you saw this on the board, this is of course, what number?

  • Yeah, 123 right?

  • It's all very intuitive to us.

  • But why, really?

  • All I did was draw three symbols on the board.

  • I kind of went like this and then this kind of curvy stroke and then a slightly more curvy stroke and drew the symbols on the board.

  • But you all sort of instinctively assigned meaning to each of these symbols and quickly, mathematically got to 123.

  • But why is that?

  • Well, if you're like me in the U.

  • S.

  • I grew up learning that this is kind of the ones place with one's column.

  • This is the tens place or the tens column.

  • This is the hundreds place with hundreds column and then so forth to keep multiplying by 10.

  • And so the reason that 123 is 123 is because this is technically 100 times one, and this is 10 times too.

  • And this is one times three.

  • That, of course, is 100 plus 20 plus three.

  • And this, of course, is 123.

  • Now, this might seem like circular logic, cause I've literally written down the same thing.

  • But now we've described meaning to do look positions of each of those symbols on the board.

  • Now, what are these places really representing not to get too technical, but their just powers of 10 right?

  • The ones place is technically 10 to the zero, cause tens of the zero is one.

  • The next place is actually 10 to the one intend to.

  • The one is 10.

  • This is of course, 10 squared or tend to the two.

  • And that gives you 100 so tend to the three tens of the 4 10 to the five.

  • These are just powers of 10.

  • So a computer and most of you a moment ago claim not to speak binary.

  • Ah, computer is fundamentally really the same exact thing.

  • Except each of the places is not a power of 10.

  • It's probably a power of to instead, right?

  • We humans sort of now naturally these days speak decimal dec meaning 10 and that 0123456789 Computer turns out, speaks binary and by convention, ah, computer only understand zero in one.

  • And that might seem very limiting at first glance.

  • But if this is the ones place now, this is the twos place.

  • This is the fourth place than 8 16 32 We can represent the exact same numbers just with different patterns.

  • But now the symbols I can draw are not zero through nine.

  • They're zero through one, so a little more limiting.

  • But that's okay, because the columns will allow me to do the same kind of math.

  • So, for instance, given this logic, if the only two things I can write with this talk is a zero or a one, how do we represent in binary?

  • That is zeros and ones only.

  • The number we humans know as zero.

  • Yeah.

  • Yeah.

  • So 000 It's kind of trivial.

  • Why?

  • While just four times zero plus two times zero plus one time zero is still zero.

  • So that one's not that interesting.

  • How would we represent the number we humans know in decimal as one 001001 And this is where it might get a little tricky for a moment.

  • How about two?

  • Yeah, 010 And this is where Now we see the connection to what I was doing with my fingers.

  • I didn't go 012 The second time, I went 012 thereby changing my finger from like a 1 to 0 and zero to a one to give me this pattern and Of course, if you want to represent three, it's gonna be Yeah, 011 And now, how about seven?

  • Yeah, 111 Right, cause that's four times one plus two times one plus one times one.

  • So four plus two plus one is seven.

  • And then maybe your question, how do we represent eight?

  • Yeah, we need another place holder, and that's fine.

  • You know, if if we were on a piece of paper or a board, I can, of course, just write a one here.

  • And then these, of course, now need to become zeros because implicit to the left here was gonna be the eights place, even though I don't need to write it from the gecko.

  • But there's now a limitation.

  • Computers, of course, or physical devices.

  • And even if you have the fanciest of Macs or PCs like you only have so much room in that computer, you only have so much memory, so much hardware.

  • So it's certainly finite.

  • And so let's actually dive down into what's inside of a computer such that you can actually represent the number seven or eight or anything in between using an actual computer.

  • Well, turns out that inside of a computer are in simple form, just like lots of tiny little light bulbs or, more specifically, little switches that could be turned on and off.

  • And those switches, when turned on and off, either allow you to store a little bit of electricity that came from the wall or the battery or allow it to dissipate and go away.

  • So those switches air called transistors.

  • If you've heard the term transistors, just a tiny little microscopic switch and CP used these days central processing units, the brains inside of a computer, the intel inside hardware has millions of these tiny little switches.

  • But for the moment, I only have three of these switches.

  • And so I claim that the number I'm currently representing with these three light bulbs is what number if they're all off zero.

  • So if you shrunk these things, light bulbs down, put them into your phone or computer.

  • That's effectively.

  • It was very dramatic with all the chalk.

  • That's effectively, how your computer, which store?

  • Zero.

  • And if you want to to store the number one well, you might just turn one of the transistors on store.

  • Little bit of electricity so Now the computer recognizes this pattern of electricity.

  • If I want to represent to do I want to just d'oh this?

  • No.

  • So this should go off because this is the ones column twos column Force column.

  • So this is to this, Of course, is three.

  • Four is You do this one here.

  • So, Ford, this goes off Off.

  • That's four five all the way over here.

  • Okay.

  • Six middle.

  • Yep.

  • And finally seven.

  • And now you see the physical problem?

  • What if you want to represent eight?

  • While all of us would have just carried the one so to speak, just as I did on the board.

  • So Okay, that's a zero.

  • That zero.

  • That zero when Damn, like we're now out of space and less.

  • Of course.

  • Thankfully, the team brought another light bulb, and now you have more memory, right?

  • And so here, in lies kind of the origins of why you run out of memories sometimes and what it means to run out of memory just means you can't count as high or you can't store for instance, as many files in your computer's memory at once, or you can't load as many programs at once.

  • because at some point you do run out of physical space.

  • But it really just boils down to these very simple primitives.

  • So literally everything inside of your computer ultimately boils down to zeros and ones.

  • Tiny little switches, if you will.

  • Those transistors that just store patterns of electricity, thereby representing values and without getting ahead of ourselves.

  • If you were to study a hardware class in computer science and really becoming a collector, okay, electrical engineer, you would also explore the reality that when you have an Intel CPU, Intel is inside.

  • Not only does that see if you know how to store information, it also has no.

  • It also knows how to perform certain operations.

  • Addition, subtraction, moving values from this location in memory over here or vice versa.

  • And that's what a CPU really does.

  • It just manipulates the zeros and ones, moves them around, adds them together and so forth.

  • But for now, let's leverage a principal in computer science that's known as abstraction.

  • And abstraction is just this general technique whereby you take a very simple, if like, boring idea and we just all agree.

  • Okay, I get it.

  • I understand that the computers can count to seven or eight or two higher.

  • But I don't really care here on out how they do it, right?

  • Certainly in the business world, it's rare that you're going to need to, you know, make any arguments in binary.

  • But that's fine.

  • We can abstract on top of this and just stipulate computers can count as high as they want, so long as they have enough memory.

  • There is a way of doing that.

  • But how do we represent other pieces of information?

  • Right?

  • Computers don't just do math.

  • They don't just run excel and calculators.

  • They have word processing programs.

  • They have spreadsheets, power point tools.

  • So there's words and letters.

  • So does anyone wanna wager a guess that how a computer can represent not numbers but rather letters of the alphabet?

  • Let's Jaime asking table.

  • Okay, so that's Ah, that's a loaded answer.

  • What do you mean by asking?

  • Table charge?

  • Yeah, change what?

  • Okay.

  • And let me focus on part of the answer before we introduce what this term is asking.

  • I like your idea of just like a chart.

  • So if we want to represent the letter A but at the end of the day all computers can represent is, you know, numbers, zeros and ones or really decimal numbers by turning switches on and off.

  • Well, why don't we all just agree that you know what?

  • Any time you want to represent the letter A thank you with Microsoft Word or Gruel Docks.

  • Why don't we just have the computer store?

  • I don't know, like the number one.

  • And any time the computer wants to store the letter B store, the number two and see could be the number three and so forth.

  • In other words, if we all just agree, is humans using these computers to use the same patterns of bits and bit, if you've ever wondered, is just binary digit?

  • It's a conjunction of the two bit binary digit.

  • It's a zero or one if we just agree that all of these could be represented, yes, and switches in transistors, a zeros and ones.

  • Well, let's just agree that any time you're writing an email or a document and you type the letter a let the computer is just gonna store the number one with some sequence of transistors and be the number two and so forth.

  • Now it turns out, that's all.

  • Computer does indeed to store text, but for whatever reason, humans did not choose simple numbers like 123 It turns out that decades ago humans decided that the letter A she'll be 65 be.

  • She'll be 66 see Shelby 67 so forth.

  • And there's other numbers for things like punctuation and for lower case letters and a few other symbols you would see on the typical keyboard.

  • And that, indeed is, as Jaime notes, is a system called asking Happens to be the American Standard Code for Information Interchange and the American in the acronym There is actually Germaine, because we were a little selfish.

  • We didn't really leave room for things like accented characters or Till Does, or any number of Asian characters that you might need asking on.

  • Lee used seven bits, so a pattern of seven light bulbs and it turns out, with seven light bulbs, you can only count as high as 128.

  • It turns out, if you do out the math, so that means you can have a total of 128 characters in your alphabet, which means there were no accented A's or B's or tell those on ends, let alone various Asian characters.

  • It was, by design, very American centric.

  • So this was asking.

  • But there's something new Earth that has actually addressed that problem.

  • Anyone know what that is?

  • There's another term that describes same idea.

  • It's just a different chart.

  • But Maur inclusive it.

  • Felix.

  • Yeah, so you know, code.

  • If you've ever heard the expression sort of, you know, one code for everyone uses either seven or really eight bits as needed or sometimes 16 bits or sometimes 24 bits, or even sometimes 32 bits.

  • That is a lot of light bulbs to represent letters.

  • And frankly, if you have 32 light bulbs, each of which could be on or off, does anyone want to guess how many possible patterns of light bulbs there are?

  • If you have 32 of them total, how high can you count?

  • In other words, I heard 1,000,000,000 so it's actually roughly four billion.

  • So if I had 32 light bulbs here, which doesn't seem like a crazy amount, I could actually per mute those switches on and off in different patterns in four billion different ways.

  • Which is to say Unicode has a lot of room for any and all characters.

  • So what are the implications of this?

  • Well, let's just see how this might map.

  • So if the capital A is 65 let's see how we might actually look at an actual word in asking.

  • So here's Ah, quick cheat sheet.

  • That's a little longer than the one I drew here, a 65 iess 73 so forth supposed that you received a text message or email.

  • And if you really looked underneath the hood of the computer, like what pattern of bits is it storing when you got that text message or that email?

  • Suppose that the pattern of bits you received happen to be a bunch of zeros and ones that if you do out the math like we did over here, works out to be the number 72.

  • Then the number 73.

  • Yeah, so you'd literally just got a text message or an email that says h I or high, And that's why so your comm phone or your computer might have gotten, what, eight or 16 total bits that were on and off in the right patterns to represent the decimal number 72 or 73 And your phone because its context sensitive or your laptop Because it knows you have the text messaging program open or you have your email program open.

  • It's not gonna show you zeros and ones.

  • It's not gonna show you decimal numbers, like in a calculator or spreadsheet.

  • It's gonna show you the corresponding asking or Unicode letters, which is a tch, I question.

  • No.

  • So what if you got, like, one more character, this one you would have to guess?

  • But suppose that the pattern were 72 73 33.

  • Anyone want to guess what message you just got?

  • Hi.

  • With a exclamation points are like, Hi, this would be in a more excited one, and you wouldn't know this other than by looking it up.

  • And indeed, you can Google ask each art or Unicode chart and you can see the hundreds or thousands of pairings of letters and numbers.

  • But yes, 33 happens to be the number that some Americans years ago decided shall represent an exclamation points.

  • So that's all nice and good.

  • But of course, in the world we have, ah, other letters that we want to represents, not just with these patterns of H I and an exclamation point.

  • What if we want to abstract further on that and actually get more familiar symbols that are all the more common in the language, like Spanish like these, where you want accented characters?

  • Well, that's where you need Unicode, because it turns out you can't cram all of those possible letters into just seven bits of patterns.

  • So we need Unicode.

  • And it turns out that one of the reasons for this trend these days that I'm sure you have down here these things called emojis right.

  • These look like pictures.

  • But they're not, technically pictures these air characters, these air characters like A and B and C.

  • It's just that they happen to be more graphical.

  • Why?

  • Well, partly because once you have four billion possible values for every letter in your alphabet, that frankly just leaves a lot of free room toe like be creative.

  • And so humans every year lately have been adding more and more symbols to Unicode to represent human emotions and smileys like this, and characters and so forth.

  • But they literally are just characters that maybe in the future you could type a smiley face on your computer because it's an actual key.

  • So as an aside, when we talk about Unicode, this is Ah, faced with tears of joy.

  • It's apparently, according to Apple, at least the most popular emoji right now.

  • Does anyone want to guess what number is used to represent Face with tears of joy?

  • 65 66 67 are already taken, so it's some other number.

  • Any guesses between could be between 33 64 if only because those are the only ones we haven't looked at yet.

  • They didn't Emojis didn't come out early enough to fit in that range, so they're actually much bigger values.

  • Yeah, maybe 500.

  • But you'd have to go even further because there's a lot of darn emojis these days.

  • Yeah, lives.

  • I want a cease to two that was strangely precise.

  • But yes, perhaps, And indeed if we actually do this in decimal, if you receive a text message with a face with tears of joy today, your phone or a laptop has just received literally a pattern of bits that represents the number 128,514.

  • Why, just because that one was available and all of those other variants of Smiley's air a little bigger than this number and a little smaller, Which just means you get a pattern of bits that your phone or your laptop interprets as that smiley face.

  • Because of the context.

  • If you're in the text messaging program or in your email program, they're displayed his pictures and not as numbers as they might be.

  • If that same pattern of zeros and ones were received in, like an Excel file or some calculator type format, it just depends on the context.

  • So any questions, then on unit code?

  • Or have this how computers do this mapping?

  • And again, the goal at hand is how do we represent information, inputs and outputs?

  • We did zeros and ones we did decimal.

  • We did letters and emojis Yeah, we know how.

  • No, no, no work stream or really good question.

  • So computers have generally standardized how many bits it uses at a time to represent information, even if some of those bits are wasted.

  • So in our human world I stopped.

  • I did.

  • I could have written not just 123 I could have written 0123 or 00123 or 000123 Those are all the same mathematically, but I just don't cause it's stupid, right?

  • Why write numbers that you don't need to?

  • But computers to avoid the ambiguity that you identify, always use.

  • We're almost always used eight bits at a time, or 16 or 24 or 32.

  • They use some multiple of eight typically, and that means that you can distinguish one character's ending from the next character.

  • Start by looking at those boundaries.

  • Really good question.

  • Other systems, if you're familiar with Morse code, do not have this feature, and so you can get ambiguous words out of Morse code because sometimes a dot on the dash might actually be a dash and a dot in a different context, depending on where you separate them.

  • Really good question.

  • All right, so we have zeros and, well, actually at the lowest level, we have, like electricity literally coming out of the wall or the floor.

  • Then we have zeros and ones that we can represent by just turning switches on and off from zeros and ones we get decimal, and from decimal, we can get to ask e.

  • So again, these air sort of levels of abstraction sort of conceptually we're working our way up.

  • So we never again have to think about binary, let alone electricity.

  • But what about more interesting aspects of a computer?

  • Is not just text, but but about something like colors, even if you've never thought about, you've probably seen this acronym like Red, Green Blue is what it denotes in English, and that just refers to a convention just like asking your Unicode, where by humans use patterns of bits, zeros and ones to represent colors as well.

  • And they do so by mixing some amount of red, some amount of green, some amount of blue together, and depending on how you mix those three colors, you can get any color of the rainbow.

  • You just need to specify how much red or green or blue you actually want.

  • So it turns out that computers typically use eight bits, which again is a multiple of eight, as I noted, to represent how much red, How much green, how much blue, which is to say eight plus eight plus 8 24 bits are typically used total to represent colors on a screen.

  • So if the smallest number you can represent with a Pitts is, of course, zero right, all the light bulbs are off.

  • The largest number you can represent with eight bits, happens to be 255.

  • If we did out the math, that just implies that if you want no read, this should be zero.

  • But if you want a lot of red, that should be 2 55 and same for green and blue.

  • So in that context, if you were to look inside of your computer and discover that your computer is storing 72 amount of red, 73 amount of green and 33 amount of blue, recall that those same numbers or bad patterns in the context of a text message or an email might ever actually represent high exclamation point.

  • But if you were to open photo shop or some graphical program that is interpreted supposed to show colors, not letters, any guesses as to what you get by combining like a medium amount of red, a medium amount of green and just a little bit of blue and again the ranges from 0 to 2 55 Anyone want to guess what you get when you combine those colors?

  • Yeah, it's a shade of yellow.

  • It looks quite like this here.

  • Why?

  • Well, that's just what happens when you combine those wavelengths of light.

  • Essentially.

  • So what does this mean?

  • Well, if you've ever looked really close on your computer screen or even a flat screen TV, you might have seen actual dots like things get kind of splotchy.

  • The closer you're human eyes get.

  • What are those things called that you're looking at the dots.

  • Yeah, they're called pixels, and they literally are just dots on the screen, your TV, your phone.

  • Your laptop is just thousands of tiny little dots.

  • Little squares.

  • Each of those squares, typically in a computer, is represented with a pattern of 24 bits.

  • Eight showing how much red eight showing, How much green eight.

  • Showing how much blue.

  • And so if you think of those three colors red, green, blue just overlapping.

  • You get a single dot like this that represents 24 bits.

  • So if you've ever looked or cared how big your photographs are when you're storing them on your laptop, your phone or any of your file sizes.

  • Those file sizes are measured not in bits, but what units of measure eso megabytes.

  • Maybe you're kilobytes or gigabytes.

  • If it's a video file, will a bite B Y t e is just eight bits.

  • Why?

  • Well, one bit is generally pretty useless.

  • You can only count as high as one.

  • So units of eight were common there, too.

  • So eight bits is one bite.

  • One megabyte is one million bites.

  • Which is to say that if you have a lot of these little dots, each of which takes up eight plus eight plus eight or three bites, you can literally do out the math and figure out how big your photograph might be.

  • Because if you know, it's this many pixels wide and this many pixels tall and each of those dots takes up three bites eight bits plus eight bits plus eight bits for red, green blue.

  • You can literally do out the math and say, Oh, this photographs gonna be three megabytes because of that simple math.

  • So even though these file sizes might seem completely arbitrary, they can be mapped directly to this kind of math now is aside.

  • Computers are smart these days.

  • They compress files to save space, so it's not quite as simple as that, but as an upper bound, it indeed is.

  • And we can see this even in this emoji, right?

  • If we start zooming in digitally on this, we can start to see these pixels.

  • And if we go really close to his eyes, you'll see these squares, which are indeed just dots.

  • And so there's different colors here, like each of these yellow dots ist ordering represented one pattern.

  • This shade of black is store represented with one other pattern, and the shades of gray are slightly different patterns.

  • But that's all they are, is bits.

  • And in the context of a graphics program like photo Shop, your computer will show you them as such.

  • All right, so we got electricity, zeros and ones decimal asking or unicode now colors now images because an image is just a whole bunch of colors left to right, top to bottom.

  • What comes next?

  • Yes, So what's a video?

  • What's a movie file?

  • Yeah, it's a representation of multiple pictures, right that just fly across the screen really fast, creating the illusion or tricking our human brains into thinking there's actual emotion.

  • If you grew up with one of those little paper flip books, little cartoons and you flip them really fast, it looks like some cartoon is being animated.

  • But no, your brain.

  • It's just kind of inter plating, so to speak.

  • It's interpreting all that.

  • Most of those changes as movement, even though every picture is actually stationery.

  • So if you've ever heard that a Hollywood movie is 24 frames per second or 30 frames per second, which are common units of measure, that just means you're being shown by some producer 24 pictures per second or 30 pictures per second, which you're probably slightly different from each other, thereby creating the illusion of movement.

  • So now we're all the way at the top of the sort of abstraction layer here, where by now we have videos and we started with like the most mundane of details.

  • And that really is what computer science is about to not just representing information but sort of solving a problem at this level, using it as the input to another problem.

  • Using that is the import to another problem.

  • So now we're having kind of a cool conversation about video files when, at the end of the day, we just started with electricity coming out of the wall.

  • So that principle of abstraction is inherent in computer science.

  • And this is kind of the thing you learn when taking a class like that in these, an emoji is that you have.

  • If you have an iPhone, for instance, silly little video files that track your face these days.

  • They're just sequences of images being shown to you pretty quickly, looping no less.

  • And that's all.

  • An image or a video file like this might be all right.

  • So that's two out of our three topics, inputs and outputs.

  • We just need this thing in the middle.

  • But before we forge ahead, any questions?

  • Confusions?

  • Yeah, Carlos.

  • Yes, so sound is also similar where you'll typically measured like the frequency of a sound wave.

  • So how quickly it's going up and down and also the wavelength, both of which can really be encoded as numbers as well as ones and zeros.

  • Indeed, indeed, on back was there a question?

  • No, Daniel, how does the computer noted pixels a square.

  • Technically, it doesn't.

  • It's just hardware.

  • Devices have decided that picture all shall be squares.

  • And so therefore, when you store an image, you should assume that every dot is same height as it is with yeah, units, Yes.

  • No.

  • Yeah.

  • Good question.

  • Okay, so some of that I can answer the rest will have to wait and see.

  • So for those cubit is kind of a cute word that refers to a bit in quantum computing.

  • Quantum computing, or cubits, essentially refers to an envisioned technology on which research is being done, where technically you can have in a device like a like a light bulb that's in both the on and the off state at the same time.

  • In some weird way, it really derives from physics.

  • And so, with cubits, you have the ability, at first glance to storm or than just a single bit of information.

  • You can store Cuba, which is mawr in the sense that it can be in two states at once.

  • This is dangerous, theoretically, because a lot of the world's security these days relies on cryptography, the art of encrypting or scrambling information, and a lot of encryption relies on the perceived difficulty of solving certain mathematical problems quickly.

  • For instance, it is really hard to take a really big number and factor it.

  • That is, break it down into two smaller numbers that, if multiplied together, give you that big number.

  • But with quantum computing and cubits, if you have the ability to essentially be in multiple states at a time and therefore do multiple types of work simultaneously, the presumption is that that is bad for things like cryptography, because you could solve problems much more quickly now, how soon that's gonna happen, or if it's gonna happen that I don't know for that.

  • Take your In Kai's course on quantum computing.

  • Perhaps, but that's a whole field of research unto itself.

  • So let's look now into this.

  • This black box, literally so in between your inputs and outputs is like the real intellectual property, the secret sauce violet.

  • You want to solve problems, and those air, generally called algorithms an algorithm, is just step by step instructions for solving a problem.

  • It's kind of a nice fancy word, but it really is just that.

  • It's like a list of commands or instructions that you feed to a human or to a robot or to a computer.

  • So what's wasn't such algorithm?

  • Well, back in the day, we like you use thes this technology here, phone books in which you have lots of names and numbers, and the names are hopefully sorted from A to Z and the numbers then line up with the individuals names.

  • And so if I wanted to look up a friend or colleagues phone number, I could just look up that number and then call them.

  • So I don't know why I'm explaining how a phone book works, but it's very similar to this technology now.

  • In fact, even though we don't really use these devices anymore, it's the same problem, right?

  • You probably have an icon on your phone iPhone or Android that is your contacts, and they're just sorted alphabetically, top to bottom.

  • But if you type searching at the top and you start typing like D A for David or a J over Jose, you'd like to think that it jumps right to that result.

  • That's the same problem.

  • It's just the software is jumping to Jose or to David's name very quickly.

  • But how is your phone doing that, or how would we humans do it back in the day?

  • Well, this is a problem to be solved in the input is this physical book.

  • And so maybe I'll start at the beginning and look at one page and I look down and maybe I'm looking for my friend Mike Smith.

  • Last name S M I t h So Smith s o.

  • If I just look at each page, I'm not seeing him yet, but this is an algorithm for each page.

  • Look down.

  • And if Mike's there, call him.

  • Otherwise moved to the next page and we wouldn't even think about it.

  • You would just do it.

  • Is this algorithm the step by step process?

  • Correct.

  • Yeah.

  • I mean, if Mike is here, we'll find him.

  • But what's the catch?

  • It's gonna take forever?

  • I mean, this is a stupid algorithm, but it's correct, right?

  • If Mike is in this phone book, I will eventually find him, Probably way back here.

  • So what would be slightly smarter?

  • Well, let me just do 2468 10 12.

  • It's hard to do physically, but it does sound like it's going twice as fast.

  • Is that algorithm.

  • Correct.

  • Okay.

  • Why?

  • Yeah, do with me.

  • Yeah.

  • So I could get unlucky and maybe I you know, he gets sandwiched in between two pages, and I just missed him altogether.

  • And I conclude, No, there's no Mike Smith here.

  • Now, I could fix that bug.

  • That mistake.

  • And it, for instance, if I hit the t section names starting with tea or s n instead of sm, I could maybe double back a page or two, and that's not very expensive.

  • It doesn't take me a huge amount of time, and I can fix that bug, but it would be roughly twice as fast.

  • But no one's gonna do that either.

  • What's most any human?

  • Gonna?

  • D'oh Heard open till like the middle.

  • All right, I look down.

  • I mean, the M section.

  • So Smith is is this way.

  • So what do I do next?

  • So I repeat, But I could more dramatically tear the problem in half, throw half of the problem away, and now I'm left with same problem.

  • Where's Mike Smith?

  • But it's half is big, so I hope that's ah, socially acceptable.

  • The tear phone books in Costa Rica because we do this all the time in the U.

  • S.

  • But these are hard to find to, though.

  • So Mike Smith is somewhere in this phone book.

  • Where is he?

  • Well, let me just go roughly two like the middle and I look down.

  • Oh, I went a little too far t section now, but now I know that Mike is not in this half of the farm book, and so I can tear that half of the problem away.

  • And what's compelling here is where is that first algorithm was very lazily going.

  • 123 or maybe 246 If I started with, like, 1000 pages in this pretty thick phonebook I just went from 1000 toe 500 to 2 50 I'm really taking big bites out of this problem.

  • And if I just repeat that same algorithm again and again, I'll probably be left ultimately with just one page that Mike is either on or not.

  • So just as an aside, suppose that phone book did have, like, 1000 pages.

  • How many times must I have to turn it to find Mike Smith the first way?

  • One page at a time, like 700 worst case 1000 but like, you know, 700 cause it's, you know, it's more than halfway through.

  • What about the third algorithm, where I divided and conquered, so to speak, splitting in half every time?

  • Yeah, eight or nine to even fewer.

  • A little more.

  • It's probably eight or nine, maybe 10 depending on how we round.

  • But yeah, if you start with 1000 pages and do the math, you go from 1000 to 500 to 2 50 to 1 25 and so forth.

  • You can only have 1000 roughly 10 times, depending on how you round.

  • So that's pretty powerful.

  • It might take me 700 steps to find Mike Smith in the first algorithm, but my God, like 10 steps in the third algorithm with the same inputs and outputs.

  • So computer science to is all about just kind of harnessing, frankly, our human intuition and expressing ourselves a little more carefully, putting a little more thought into the problem and then getting much, much faster or more efficient results.

  • And so how might we then quantify this difference?

  • We don't have to even talk numbers very specifically, but if this is just a chart, and here is the size of the problem.

  • So this is like, number of pages.

  • So a lot of pages over here, a few pages over here, right toe left, vertical access time to solve.

  • So maybe zero seconds and a lot of seconds could be our unit of measure.

  • The first algorithm is really just a straight line.

  • Why?

  • Because if the phone company adds one more page to the phone book next year, that just means it's gonna take me one more page turn or one more units of time.

  • So it's a slope of one, if you will.

  • The second algorithm is gonna be same shape.

  • It's a straight line, but it's lower because if the phone book has this many pages, the first algorithm might take me this money steps.

  • But the other algorithm where I'm going to pages at a time takes half assed many steps, so the line is the same shape, but it's just lower on the chart.

  • The third algorithm, though, is fundamentally better, and it's a log arrhythmic curve, if you will, and even if a little rusty on what a lager of them is, it's a curve that looks like this.

  • It's always increasing, but it increases more slowly and slowly and slowly.

  • The implication is that suppose that the phone company next year like double the number of pages in the phone book.

  • Well, how many more steps with the first algorithm take?

  • If you went from 1000 pages to 2000 like another 2000 steps right, like Mike might be 1400 pages in twice a SW far and if the phone book is twice as big but no big deal for the third algorithm if the phone company doubles the size of the phone book because maybe two towns combined phone books how many more steps will find next year take to find Mike Smith next year?

  • Just one right?

  • No big deal.

  • Tear it in half, one more time and so algorithms.

  • When you think about the efficiency and when software engineers sort of compare the efficiency of their code and try to claim that our product is better, our product is faster.

  • You can absolutely just measure it by counting seconds on the clock.

  • But you can also make more theoretically sound arguments and say, Well, our algorithm is fundamentally better than yours because look, as n gets large were, and it's just the number of pages in the phone book.

  • It barely takes us any more time.

  • And so it's the Facebooks of the world and the Googles of the world that really care about getting algorithms not just correct, but efficient.

  • So is to leverage that those kinds of implications and oracle in any database company.

  • It's similarly trying to invent algorithms like that.

  • Any questions there?

  • All right, well, let's formalize that all of us just kind of intuited that a moment ago.

  • But let's introduce one language today and firm or languages.

  • You can take CS 50 it in Chi with Jose and Hai Mai and team next term and beyond.

  • But pseudo code is not an actual language.

  • It's like a language like syntax most people write in English.

  • You can write it in any spoken language, though, and it's just meant to be short, succinct instructions that get your idea across to another human before you write actual code.

  • And here is how we might write the pseudo code for that algorithm to find Mike Smith, where I divided and conquered.

  • Step zero was pick up the phone book.

  • Step one, Open to the middle of the phone book.

  • Step two.

  • Well, look at the names and then I make a decision.

  • If Smith is among the names that I'm looking at, then I'm gonna go ahead and call Mike.

  • But that's not the only possibility.

  • It might be the case that Excuse me.

  • Smith is earlier in the book, in which case I should open to the middle of the left half of the book and then, frankly, just go back to Step two because I already have the same logic ready to go else.

  • If Mike is later in the book, open to the middle of the right half of the book and then also go back to step to else quit because Mike presumably is not in the book.

  • If he's not there or to the left or to the right, it must be he's just not in the phone book.

  • So what are the characteristics of this program?

  • Well, in languages like Java and C plus plus and others, you see commonality.

  • So this is just pseudo code, but everything I've highlighted in yellow here in a proper programming language like python is gonna be called an ah function, and a function is just like a verb, an action that the program or the robot or the human contagion.

  • Here we have conditions or decisions that the computer can make.

  • If this go that direction else, maybe go this way.

  • It's like a fork in the road, and you have to decide which branch to go down these things a little more technically or called boolean expressions after a mathematician named Bull and a Boolean expression is just a question that has a yes or no answer or a true or false answer or, more simply, a one or zero answer ones and zeros air just really nice when you want to represent two opposing ideas, true and false, yes or no or some other idea.

  • So a Boolean expression is just going to say yes or no.

  • So Smith is later in the book.

  • It's a question or Smith earlier in the book, also a question, and then, lastly, we have this how much you describe this yellow feature.

  • N

ghost.

Subtitles and vocabulary

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