跳到主要内容

数据

AP 计算机科学原理 · 第 2 主题

训练
讲义 词汇表
2.1

二进制数

大纲
Enduring UnderstandingLearning ObjectiveEssential Knowledge

DAT-1
The way a computer represents data internally is different from the way the data are interpreted and displayed for the user. Programs are used to translate data into a representation more easily understood by people.

DAT-1.A
Explain how data can be represented using bits. [Skill 3.C]

  • DAT-1.A.1 Data values can be stored in variables, lists of items, or standalone constants and can be passed as input to (or output from) procedures.
  • DAT-1.A.2 Computing devices represent data digitally, meaning that the lowest-level components of any value are bits.
  • DAT-1.A.3 Bit is shorthand for binary digit and is either 0 or 1.
  • DAT-1.A.4 A byte is 8 bits.
  • DAT-1.A.5 Abstraction is the process of reducing complexity by focusing on the main idea. By hiding details irrelevant to the question at hand and bringing together related and useful details, abstraction reduces complexity and allows one to focus on the idea.
  • DAT-1.A.6 Bits are grouped to represent abstractions. These abstractions include, but are not limited to, numbers, characters, and color.
  • DAT-1.A.7 The same sequence of bits may represent different types of data in different contexts.
  • DAT-1.A.8 Analog data have values that change smoothly, rather than in discrete intervals, over time. Some examples of analog data include pitch and volume of music, colors of a painting, or position of a sprinter during a race.
  • DAT-1.A.9 The use of digital data to approximate real-world analog data is an example of abstraction.
  • DAT-1.A.10 Analog data can be closely approximated digitally using a sampling technique, which means measuring values of the analog signal at regular intervals called samples. The samples are measured to figure out the exact bits required to store each sample.

DAT-1.B
Explain the consequences of using bits to represent data. [Skill 1.D]

  • DAT-1.B.1 In many programming languages, integers are represented by a fixed number of bits, which limits the range of integer values and mathematical operations on those values. This limitation can result in overflow or other errors.
  • DAT-1.B.2 Other programming languages provide an abstraction through which the size of representable integers is limited only by the size of the computer's memory; this is the case for the language defined in the exam reference sheet.
  • DAT-1.B.3 In programming languages, the fixed number of bits used to represent real numbers limits the range and mathematical operations on these values; this limitation can result in round-off and other errors. Some real numbers are represented as approximations in computer storage.
    • Exclusion statement: Specific range limitations for real numbers are outside the scope of this course and the AP Exam.

DAT-1.C
For binary numbers:
a. Calculate the binary (base 2) equivalent of a positive integer (base 10) and vice versa. [Skill 2.B]
b. Compare and order binary numbers. [Skill 2.B]

  • DAT-1.C.1 Number bases, including binary and decimal, are used to represent data.
  • DAT-1.C.2 Binary (base 2) uses only combinations of the digits zero and one.
  • DAT-1.C.3 Decimal (base 10) uses only combinations of the digits $0 - 9$.
  • DAT-1.C.4 As with decimal, a digit's position in the binary sequence determines its numeric value. The numeric value is equal to the bit's value (0 or 1) multiplied by the place value of its position.
  • DAT-1.C.5 The place value of each position is determined by the base raised to the power of the position. Positions are numbered starting at the rightmost position with 0 and increasing by 1 for each subsequent position to the left.

来源:美国大学理事会 AP 课程与考试说明

计算机把一切存储为(bits)——每个是一个 01。一组 8 位是一个字节(byte)。数字以二进制(binary)(基数 2)存储,其中每一位是二的一个幂($1, 2, 4, 8, 16, \dots$),而不是十进制(decimal)里十的幂。例如,二进制 1011$8+2+1=11$

一个 8 位的位值图:1 坐在加起来等于这个数的值之下
一个 8 位的位值图:1 坐在加起来等于这个数的值之下

Worked example. 要把二进制 1101 转换成十进制,把位值 8 4 2 1 写在位 1 1 0 1 之下并加上有一个 1 的那些:$8+4+0+1=13$。反过来,通过减去合适的最大二的幂把 19 转换成二进制:$19-16=3$,然后 $3-2=1$,然后 $1-1=0$,所以位坐在 1621$\rightarrow$ 10011(检查:$16+2+1=19$)。

因为一台计算机有有限数量的位,它只能表示一个有限范围的值。这造成考试上考查的两个效应:

  • 溢出错误(overflow error):一个对可用的位太大的数不能被正确地存储。
  • 舍入错误(round-off (rounding) error):带小数的数(实数)只能被近似,因为无穷多个实数值必须映射到有限多个位模式上。

所有数据——文本、图像、声音——最终都被编码为二进制。一个图像是一个像素(pixels)网格,每个作为它颜色的数字存储;声音作为每秒采样许多次的数字存储。

探索

Convert between binary and decimal

Computers store numbers in binary (base 2). Each bit is a power of two; add the place values of the 1-bits to read the decimal number.

词汇表 训练
英文 中文 拼音
bits wèi
byte 字节 zì jié
binary 二进制 èr jìn zhì
decimal 十进制 shí jìn zhì
Overflow error 溢出错误 yì chū cuò wù
Round-off (rounding) error 舍入错误 shě rù cuò wù
pixels 像素 xiàng sù
2.2

数据压缩

大纲
Enduring UnderstandingLearning ObjectiveEssential Knowledge

DAT-1
The way a computer represents data internally is different from the way the data are interpreted and displayed for the user. Programs are used to translate data into a representation more easily understood by people.

DAT-1.D
Compare data compression algorithms to determine which is best in a particular context. [Skill 1.D]

  • DAT-1.D.1 Data compression can reduce the size (number of bits) of transmitted or stored data.
  • DAT-1.D.2 Fewer bits does not necessarily mean less information.
  • DAT-1.D.3 The amount of size reduction from compression depends on both the amount of redundancy in the original data representation and the compression algorithm applied.
  • DAT-1.D.4 Lossless data compression algorithms can usually reduce the number of bits stored or transmitted while guaranteeing complete reconstruction of the original data.
  • DAT-1.D.5 Lossy data compression algorithms can significantly reduce the number of bits stored or transmitted but only allow reconstruction of an approximation of the original data.
  • DAT-1.D.6 Lossy data compression algorithms can usually reduce the number of bits stored or transmitted more than lossless compression algorithms.
  • DAT-1.D.7 In situations where quality or ability to reconstruct the original is maximally important, lossless compression algorithms are typically chosen.
  • DAT-1.D.8 In situations where minimizing data size or transmission time is maximally important, lossy compression algorithms are typically chosen.

来源:美国大学理事会 AP 课程与考试说明

压缩(compression)减少存储或发送数据所需的位数。两种:

压缩方法:无损与有损,带常见例子
压缩方法:无损与有损,带常见例子
  • 无损压缩(lossless compression)让你能恢复精确的原始数据(用于文本和程序,那里每一位都重要)。
  • 有损压缩(lossy compression)扔掉一些数据以进一步缩小大小(用于照片、音乐、视频,那里一个小的质量损失可接受)。

在它们之间选择权衡大小与保真度:无损保留一切但节省更少;有损节省更多但永久地失去细节。当数据必须精确时偏好无损。

探索

Compress a run of repeats

Run-length encoding is a lossless compression: a long run of the same symbol is replaced by the symbol and a count, shrinking the data with no information lost.

词汇表 训练
英文 中文 拼音
Compression 压缩 yā suō
Lossless compression 无损压缩 wú sǔn yā suō
Lossy compression 有损压缩 yǒu sǔn yā suō
2.3

从数据中提取信息

大纲
Enduring UnderstandingLearning ObjectiveEssential Knowledge

DAT-2
Programs can be used to process data, which allows users to discover information and create new knowledge.

DAT-2.A
Describe what information can be extracted from data. [Skill 5.B]

  • DAT-2.A.1 Information is the collection of facts and patterns extracted from data.
  • DAT-2.A.2 Data provide opportunities for identifying trends, making connections, and addressing problems.
  • DAT-2.A.3 Digitally processed data may show correlation between variables. A correlation found in data does not necessarily indicate that a causal relationship exists. Additional research is needed to understand the exact nature of the relationship.
  • DAT-2.A.4 Often, a single source does not contain the data needed to draw a conclusion. It may be necessary to combine data from a variety of sources to formulate a conclusion.

DAT-2.B
Describe what information can be extracted from metadata. [Skill 5.B]

  • DAT-2.B.1 Metadata are data about data. For example, the piece of data may be an image, while the metadata may include the date of creation or the file size of the image.
  • DAT-2.B.2 Changes and deletions made to metadata do not change the primary data.
  • DAT-2.B.3 Metadata are used for finding, organizing, and managing information.
  • DAT-2.B.4 Metadata can increase the effective use of data or data sets by providing additional information.
  • DAT-2.B.5 Metadata allow data to be structured and organized.

DAT-2.C
Identify the challenges associated with processing data. [Skill 5.D]

  • DAT-2.C.1 The ability to process data depends on the capabilities of the users and their tools.
  • DAT-2.C.2 Data sets pose challenges regardless of size, such as:
    • the need to clean data
    • incomplete data
    • invalid data
    • the need to combine data sources
  • DAT-2.C.3 Depending on how data were collected, they may not be uniform. For example, if users enter data into an open field, the way they choose to abbreviate, spell, or capitalize something may vary from user to user.
  • DAT-2.C.4 Cleaning data is a process that makes the data uniform without changing their meaning (e.g., replacing all equivalent abbreviations, spellings, and capitalizations with the same word).
  • DAT-2.C.5 Problems of bias are often created by the type or source of data being collected. Bias is not eliminated by simply collecting more data.
  • DAT-2.C.6 The size of a data set affects the amount of information that can be extracted from it.
  • DAT-2.C.7 Large data sets are difficult to process using a single computer and may require parallel systems.
  • DAT-2.C.8 Scalability of systems is an important consideration when working with data sets, as the computational capacity of a system affects how data sets can be processed and stored.

来源:美国大学理事会 AP 课程与考试说明

当我们从数据(data)提取信息(information)时它变得有用——模式、趋势,和问题的答案。大数据集能揭示一个小的不能揭示的相关性,但数据必须先被清洗(cleaned)(修复错误和不一致)并常常被变换(transformed)或过滤(filtered)。两样东西之间的一个相关性(correlation)不证明一个导致(causes)另一个——一个关键的警告。元数据(metadata)(关于数据的数据,像一张照片的日期和位置)帮助组织和搜索大搜集。

词汇表 训练
英文 中文 拼音
Data 数据 shù jù
information 信息 xìn xī
correlation 相关性 xiāng guān xìng
Metadata 元数据 yuán shù jù
2.4

用程序处理数据

大纲
Enduring UnderstandingLearning ObjectiveEssential Knowledge

DAT-2
Programs can be used to process data, which allows users to discover information and create new knowledge.

DAT-2.D
Extract information from data using a program. [Skill 2.B]

  • DAT-2.D.1 Programs can be used to process data to acquire information.
  • DAT-2.D.2 Tables, diagrams, text, and other visual tools can be used to communicate insight and knowledge gained from data.
  • DAT-2.D.3 Search tools are useful for efficiently finding information.
  • DAT-2.D.4 Data filtering systems are important tools for finding information and recognizing patterns in data.
  • DAT-2.D.5 Programs such as spreadsheets help efficiently organize and find trends in information.
  • DAT-2.D.6 Some processes that can be used to extract or modify information from data include the following:
    • transforming every element of a data set, such as doubling every element in a list, or adding a parent's email to every student record
    • filtering a data set, such as keeping only the positive numbers from a list, or keeping only students who signed up for band from a record of all the students
    • combining or comparing data in some way, such as adding up a list of numbers, or finding the student who has the highest GPA
    • visualizing a data set through a chart, graph, or other visual representation

DAT-2.E
Explain how programs can be used to gain insight and knowledge from data. [Skill 5.B]

  • DAT-2.E.1 Programs are used in an iterative and interactive way when processing information to allow users to gain insight and knowledge about data.
  • DAT-2.E.2 Programmers can use programs to filter and clean digital data, thereby gaining insight and knowledge.
  • DAT-2.E.3 Combining data sources, clustering data, and classifying data are parts of the process of using programs to gain insight and knowledge from data.
  • DAT-2.E.4 Insight and knowledge can be obtained from translating and transforming digitally represented information.
  • DAT-2.E.5 Patterns can emerge when data are transformed using programs.

来源:美国大学理事会 AP 课程与考试说明

程序以人类不能的规模处理数据。常见的操作是过滤(filtering)(只保留满足一个条件的行)、清洗(cleaning)(移除错误),和可视化(visualizing)(使模式可见的图表)。组合来自多个来源的数据能揭示更多,但引发隐私(privacy)顾虑。交互式工具和可视化让人们探索数据并得出他们自己的结论。

考试技能: 能够解释一个程序如何帮助在一个大数据集里找到信息,以及为什么数据里显示的相关性不建立因果关系。

词汇表 训练
英文 中文 拼音
filtering 过滤 guò lǜ
visualizing 可视化 kě shì huà
privacy 隐私 yǐn sī
2.4

考试技巧

  • 自信地在二进制、十进制和(在被要求时)十六进制之间转换——练习直到它快速。
  • 记住一个位是一个二进制数字而一个字节是 8 位;$n$ 位表示 $2^n$ 个值。
  • 解释所有数据——数字、文本、图像、声音——都存储为二进制,而有限的位造成溢出舍入
  • 区分无损有损压缩以及每个何时合适。
  • 展示模拟到数字的思想:采样(sampling)把一个连续信号变成离散的值。

本主题的互动课程

逐步学习,并即时检测练习。

AP 计算机科学原理历年真题

AP 计算机科学原理的更多主题

登录或创建账号

IGCSE, A-Level & AP