ProgrammingMethodology-Lecture14.pdf
(
62 KB
)
Pobierz
Programming Methodology-Lecture14
Instructor (Mehran Sahami):
Are we on? All right. Looks like we’re on. Let’s go ahead
and gets started with a few announcements.
So hopefully you’re still turning in, or you will be turning in, your assignment three soon.
There is three hand-outs today. They’re not all in the back there right now. There was a
huge problem with the copier today, and Ben is actually gone to make — to finish up
making all the copies of all the handouts by the end of the class. So at the end of class
you can pick up all three handouts. Some of you may have already picked up one. There
was some copies back there. But the three handouts are basically your next assignment,
assignment number four, which is a hangman game. So you’ll be doing another game.
This one’s a little less graphically involved, unless you actually want to add a lot of
graphics, which is another fun extension you can add to it if you want. But it sort of
involves much more algorithmics with strings and also gives you practice using multiple
classes. So this whole time we’ve talked about, oh, you can have all these different
classes. Well, this is your chance to actually use multiple classes starting now in
hangman.
The other two handouts are the practice midterm and practice midterm solutions. So those
will also be here at the end of class. That will give you a whole bunch of details about the
midterm and what the midterm actually covers, but it will also give you examples of real
exam problems that have been given in the past. So you can work on them. Do it in the
time, you know, time sort of setting so you can see what you’re slow on and what you’re
fast on. But it’s kind of in flavor, very similar, to what the real exam’s gonna be in terms
of what it covers, the kind of complexity of the problems, et cetera. So you can get that
after class.
Last time to announce it. If there is midterm conflicts, email me by 5:00 p.m. today. So if
you have an unmovable academic conflict with the midterm next week on Tuesday, 7:00
to 8:30 p.m., send me an email by 5:00 p.m. today. After 5:00 p.m. today I’m gonna take
all the emails that I’ve got and try to figure out a time that everyone can make based on
those emails and schedule the alternate time. So after 5:00 p.m. today I can’t
accommodate any other requests, unless of course you happen to be free at the alternate
time you schedule, in which case you sort of got lucky. But if you have a conflict with the
midterm, 5:00 p.m. today, send me email. That’s the deadline.
Just in case you’re wondering where you would actually take the midterm, it’s in Kresge
Auditorium, one of the few buildings on campus that’s actually large enough to
accommodate this class with alternate seating. So Kresge Aud. Anyone know what the
significance of the, “K,” in “Kresge” is? It’s the same as the, “K,” in “Kmart.” So anyone
ever gone to Kmart? Ever seen a Kmart? That’s like Kresge-mart. That’s where the, “K,”
comes from. So you wonder where all that money came from to donate that huge
building. So midterm’s in Kresge.
Along somewhat different lines then, we’re gonna make a slight change to the syllabus.
This won’t affect anything that’s on the midterm because the midterm will only cover
stuff through today. Anything after today is not fair game for the midterm, will be fair
game for the final exam. But a small change to the syllabus is — Friday’s class will
remain the same. We’ll talk about files. But next week on Monday we were gonna start
talking about debugging strategies. And I’m gonna defer that lecture until after the
midterm. So actually starting on Monday next week we’re gonna start talking about
arrays. So if you want to keep up with the reading in the syllabus, that’s Chapter 11.
We’re gonna start that on Monday, as opposed to on Wednesday. So I’ve just moved
basically things up by one day for arrays. It’s not a big deal.
And we’ll actually talk about debugging after the midterm. Part of the reason for that is
for your assignment number three — or, sorry, your assignment number four for
hangman, it’s actually a three-part assignment. It’s all one big program that you write, but
we sort of break it up for you into three parts. That third part that you’ll do at the very
end, which is perhaps actually the simplest part, will make use of arrays which is why
we’re gonna start talking about arrays. So you will have seen all that by the time you
actually need to do that third part.
Last but not least, as you know, assignment three is due today so quickly let’s take the
pain poll. Just wondering, how many people actually added extensions to break out?
Wow, lovely. How many people were really gunning for the plus plus? Cool. Good times.
I look forward to seeing those, so it’ll be a good time. So the — in terms of the pain poll,
I want you to just let me know how much time it took you to do the basic assignment. So
if you did extensions, don’t count the time for the extensions. What I really care about is
the base assignment.
Anyone under two hours? Just wondering. It would have been frightening if you were. I
wouldn’t expect anyone to be. Two to four? A couple people in two to four. Four to six?
That’s a pretty reasonable contingent. Six to eight? Also pretty healthy size. You can tell
that the bar drawing is a very scientific process. Eight to ten? Okay. Ten to twelve?
Beginning to quickly fall off. Twelve to fourteen? Fourteen to sixteen? I put in 16 to 18
this time just for good measure. Sixteen to eighteen? A couple folks. Eighteen plus?
Anyone taking a late day? A few folks for 18 plus, all right. And anyone taking a late
day. All right. We’ll see where you end you. I always have this tendency to think, like,
oh, if you’re taking a late day it’s like I should just count you in here, but that’s really not
the case. Sometimes you’re just like, hey, I decided to go play in the sun or whatever.
And the weather has been lovely, hasn’t it? All right. With that said, world is normal, life
is good, average is still, on average, less than ten. Everything we sort of hope for. We
sing — we hold hands, we sing Kumbaya, and the birds are out chirping. Good time.
Any qu — well, I shouldn’t ask you if there was any questions about break out because
some people are taking late days. Any questions about strings? Because after today we’re
leaving — well, actually after last time we’re sort of leaving strings behind. After right
now, we’re leaving strings behind. You will use them just to no end on the hangman
assignment because it’s all about text and strings and characters and it’s just a happy
camper that way. But if you have any questions about anything you’ve seen with strings,
ask them now or I won’t say forever hold your peace. Ask them now or ask them at office
hours, right? You can ask later.
Alrighty. So today’s the day when we lift the covers on the machine. It’s actually when
we sort of like rip open your computer, although I’m not gonna rip open a computer. I
considered doing that. But we’re gonna rip open your computer and look at what’s inside.
And it’s really, really small so you have to bear with me, okay? But we’re gonna talk
about is memory. And after today you will be experts in memory. You’ll just be like,
“Hey, man, I might not be able to remember anything, but I know all about the memory
in my computer,” which is the important memory to actually think about.
So the first thing in memory that we want to think about, right. When we talk about
memory some people have heard the term like RAM for Random Access Memory. And
so, like, you buy some new computer and you go, “Oh, I got, like, two gigs of RAM in
my computer,” right? This is what we’re gonna be talking about, is what that RAM in
your computer actually means, okay? And how it relates to your job of programs, and
why it’s all important.
So the very basic notion, the very simplest concept of memory inside the computer is
something that’s called a bit. And all a bit is — it’s actually shorthand for a binary digit.
So if you take binary digit and you squeeze it together real hard, all of sudden the
extraneous letters pop out, and you get bit, okay? And this is just a zero or a one. It is a
single binary digit. Binary being base two numbers which means there is only zeros and
ones as digits in that number system, okay? And that’s the simplest kind of thing. So
somewhere inside your computer there’s actually, like, a little piece of silicon or
whatever and a little transistor that can keep track of a zero or one. So when you get —
we won’t go below the transistor level. If you’re really interested in that take, like, you
know, an E class. But the bit is a zero or one.
And then we take a column — a whole bunch of bits, and we stick them together into
something called the byte. You’re like, oh, that whole term like gigabytes. Yeah, this is
what it’s all about. What a byte is is eight bits. Okay. So basically eight binary digits
strung together is one byte. Okay. That’s all it is. Now, one byte of memory would not be
very interesting, right? You — it’s like, oh, I could have one really small number in my
computer, right? Because eight bits can represent, like, an integer between zero and 255.
It’s not very exciting if that’s all the memory you had in your computer.
So when we think about bits and bytes, we also like to think about larger pieces. There’s
a piece sometimes people refer to as a word, which actually has nothing to do with
English words. But a word is generally the size of what an integer is used to store in some
particular language. And it turns out an integer in Java is four bytes of memory. So it’s 32
bits. Thirty-two ones and zeros comprise the space that your computer actually sets aside
for a single integer in memory, which is why an integer has some bounded sides, right?
You can’t just have a number very close to infinity in an integer because it just has some
finite size. It turns out to be four bytes. And that’s something that sometimes people refer
to as a word. We won’t use the word, “word,” very much but just so you know. What we
will talk a lot about are bytes. And so bytes — there’s a lot of terms related to bytes that
you’ve probably heard. So how many people have heard of a K or a kilobyte? Right.
Probably a lot of people. And you would like to think that the metric system, right, kilo
means what in the metric system? Thousand, right. So you would like to think a kilobyte
is a thousand bytes. But, no. Computer scientists come along and they’re like, “No, no,
no, no, no. That’s much too round and we’re not decimal people. We’re binary people.”
And the closest number to a thousand in binary is two to the tenth which is equal to
1,024.
So a kilobyte — one K when you talk to a person who’s actually a computer scientist or
someone who’s putting the RAM together for machine, you actually, sort of, get a little
extra, right. It’s kinda like there you’re, “Oh, I got some bonus RAM.” And, like, this
whole time you didn’t even know. They were just giving it to you for free, right? And so
there’s this notion of a meg, right? Like a megabyte. And a megabyte is basically just a
thousand kilobytes. As a matter of fact, it’s not just 1,000 kilobytes, it’s 1,024 kilobytes.
Because we do everything in powers of two, so it’s actually two to the 20th.
And then there is probably you — something you’ve heard of called a gig or a gigabyte,
right? These are the common ones. This is 1,024 meg. So when you start adding these all
together, right, you’re actually sort of getting a lot of bonus memory for your gig.
Because it turns out you’re getting, you know, 124 megs, and each one of your megs is
getting 124 K, and each one of your K is getting 1,024. So you’re getting a little bit of a
bonus. So now it’s time for the advanced course. You’re like, “Yeah, man, I got so much
RAM in my computer. I got gigs and gigs.” And so then I would say, “Oh, yeah, really?
You got 1,024 gigs?” Because what would that be if that’s what you had?
Student:
Terabyte.
Instructor (Mehran Sahami):
Terabyte. All right. So the next one is a terabyte. What
comes after terabyte?
Student:
Petabyte.
Instructor (Mehran Sahami):
Petabyte. Okay. And now we’re getting into dangerous
territory. So each one of these is a factor of 1,024 greater than the next one, right? What
comes after petabyte? Exabyte. There was a few folks. We’ll see how long we keep you.
How — what comes after exabyte? Anyone?
Student:
Zettabyte.
Instructor (Mehran Sahami):
Zettabyte with two, Ts. Not to be confused with
Catherine Zeta-Jones. That’s an entirely different zettabyte. So this is a zettabyte, all
right? Just horrible, wasn’t it? And then after zetta, just to drive the point home, is a
yattabyte. I always like to think of it as like a yoda byte, right? It’s just, like, so much
information you can’t even conceive of it. But it’s a yattabyte. Oh, yeah, that’s a yatta
good time. We just not even close to this, okay?
A couple things if you just want to think of orders of magnitude just so you have some
vague idea. If you took the printed collection in the U.S. Library of Congress, that’s
roughly equivalent to about ten terabytes. Is all the printed material if you thought of each
character being represented by one byte. Okay. And you’re like, “Oh, that’s interesting.”
If you took all printed material ever, that’s about 200 petabytes. So at this point we’re
getting pretty close. Like, you can go down to Fry’s, right, or some other place. I
shouldn’t name a particular manufacturer or a particular vendor. And you can probably
buy about a terabyte of storage relative — well, I shouldn’t say relatively cheaply but for
a couple hundred bucks, okay? And you kinda crank that up and you can imagine
someone for a couple hundred thousand dollars could have a petabyte, right? And then
you sort of have a couple million dollars and you could have enough storage to store all
the printed manner ever, right? Which is not that far away.
And then the — I don’t know how someone came up with this number, but I actually
found this number and I was like, how do you measure that? Which is if you took the
amount of storage that would be required to store all words ever spoken by human
beings, okay? Like, where did they get that number, and it’s increasing right now, right?
They estimate that that would be about five exabytes. Right. So we’re still sort of in this
range, right? Like, yeah, Catherine, she’s safe. And the little Zedi guy, yeah, we’re not
even close, all right? So we still got a lot more information to produce someday. And
you’re like, “Oh, I can do that now with my program. I can just have an infinite loop, and
I can generate this.” It’ll still take a while. All right. But it’s interesting just the amount of
information that we’re actually producing.
Now, when we think about actually storing all this stuff inside a computer — so now that
you’ve got some notion of, kind of, orders or magnitude for these things and what these
little bits and bytes really are — the other thing that we want to think about is what kind
of representations do we have when we actually store this stuff? So it turns out because
we like to think in binary, right, we have bits which are binary digits. Sometimes it’s
easier for us to think not just in terms of all the ones and zeros themselves but some other
base system that’s easier to keep track of. And so one you might think of is Octal, which
is base eight numbers, right? So remember when we did the little asky chart and I showed
that to you in Octal, and I was like, “Oh, these are base eight numbers.” Like, the digits
go between zero and seven. Yeah, that was Octal. That’s something that some computer
scientists do, but most computer scientists, at some point in their life, that — as a matter
of fact, I would say all of them in some point in their life. And now is that point in your
life.
We’ll deal with something called hexadecimal. And hexadecimal, hex being six —
decimal — yeah, it’s hexicomical. Hexadecimal, six, and then, “deci,” being ten is base
16. We put the six and the ten here. You’re like, “Shouldn’t that be 60?” No, it’s 16. We
add. So this is base 16 numbers. And you might say, “But, Maron, yeah, like, I remember
these three, four, five, six, seven, eight and nine and those are all fun.” And, like, when
Plik z chomika:
m_r_k
Inne pliki z tego folderu:
ProgrammingMethodology-Lecture01.html
(61 KB)
ProgrammingMethodology-Lecture01.pdf
(63 KB)
ProgrammingMethodology-Lecture11.html
(61 KB)
ProgrammingMethodology-Lecture04.pdf
(61 KB)
ProgrammingMethodology-Lecture03.pdf
(66 KB)
Inne foldery tego chomika:
Zgłoś jeśli
naruszono regulamin