# MIT《计算机科学与编程导论》第七讲

5738人阅读 评论(2)

Section 1

mutable
L1 = [1, 2, 3]
L2 = L1
L1[0] = 4
print L2 -> [4, 2, 3]

immutable
a = 1
b = a
a = 2
print b - 1

Dictionaries 字典类型
-mutable
-not ordered
-generalized indexing

Section 2

Pseudocode 伪代码
1.Module
2.Data type
3.Flow of control
4.Abstraction

Efficency 效率

In general, it's hard to come up with the really clever algorithm.
What you're much better at doing is saying how do I take the problem I've got
and map it into a class of algorithm about which I know and use the efficiencies
of those to try and figure out how to make it work.
Another way of say it is, efficiency is really about choice of algorithm. And we want
to help you learn how to map a problem into a class of algorithm of some efficiency.

How do we think about effciency? Typically, there's two things we want to measure:
space & time.
When we talk about space, what we usually refer to is, how much computer memory
does it take to complete a computation of a particular size? And by that, I mean,
not how much memory do I need to store the size of the input. It's really how much
internal memory do I use up as I go through the computation?
In this course, we really focus on the time. What is the number of the basic steps
needed as a function of the input size?

（不应该运行程序看多久运行完。因为这钟运行时间会受到很多因素影响，如机器的配置，

We're going to assume a particular model, called a random access model.
Which basically says, we're going to assume that the length of time it takes me to
get to any location in memory is constant. And the second assumption we're going
to make is the basic primitive steps take constant time, same amount of time to compute.

（对于每种编程语言不全是这样，但这个模型不错。）

Random Access Model and 3 cases to analyze
- Best case
- Worst case
- Average case

2
0

个人资料
• 访问：3394892次
• 积分：24516
• 等级：
• 排名：第317名
• 原创：314篇
• 转载：56篇
• 译文：3篇
• 评论：1594条
博客专栏
 探索编程的本质 文章：3篇 阅读：7925
 内存计算 文章：18篇 阅读：163226
最新评论