← All Units← 返回单元列表 ← Course Hub← 课程主页
A P C O M P U T E R S C I E N C E P R I N C I P L E S
Unit 2 · Solutions第 2 单元 · 解析

Data — Solutions数据 —— 解析

Companion to the AP-Style MC Practice SetAP 风格选择题练习的解析配套

MEDIUM HARD AP MC

Unit 2: Data第 2 单元:数据CSP



MULTIPLE CHOICEWorked Answers详细解析

Multiple Choice — Worked Answers选择题(Multiple Choice)—— 详细解析

Each item restates the prompt and choices, marks the correct letter, and gives a brief justification. Trap distractors are called out where useful.每道题重述题干与选项、标出正确答案字母,并给出简明解析;对容易混淆的干扰项(trap distractor)单独提示。

Q1MEDIUMAP MC2.1 Binary Numbers

A device stores an unsigned integer as the binary sequence 1011010.设备将一个无符号整数存储为二进制(binary)序列 1011010。

What is the decimal value of the integer?该整数的十进制(decimal)值是多少?

Answer:答案: (A)
  • The 1 bits have place values 64, 16, 8, and 2.
  • The value is 64 + 16 + 8 + 2 = 90.
Option B omits the 8 place. Option C uses 4 instead of 8. Option D incorrectly adds another 16.
  • 值为 1 的位对应的位值分别是 64、16、8 和 2。
  • 因此该数为 64 + 16 + 8 + 2 = 90。
选项 B 漏加了位值 8。选项 C 错把位值 8 当作 4。选项 D 多加了一个 16。
Q2MEDIUMAP MC2.1 Binary Numbers

A sensor assigns each possible reading a distinct unsigned 9-bit code. All 9-bit patterns are available.传感器为每个可能的读数分配一个不同的无符号 9 位代码。所有 9 位模式均可使用。

What is the maximum number of distinct readings that can be encoded?最多可以编码多少个不同的读数?

Answer:答案: (A)
  • Each of the 9 bits has two possible values.
  • There are 2 to the ninth power, or 512, distinct patterns.
Option B counts 8-bit patterns. Option C is the largest unsigned value, not the number of patterns. Option D counts 10-bit patterns.
  • 9 个位中的每一位都有两种可能的值。
  • 不同模式共有 2 的 9 次方,即 512 个。
选项 B 计算的是 8 位模式的数量。选项 C 是最大的无符号值,而不是模式数量。选项 D 计算的是 10 位模式的数量。
Q3HARDAP MC2.1 Binary Numbers

A museum digitizes a continuously changing sound. One version records more samples per second than another, while both use the same number of bits per sample.一家博物馆将连续变化的声音数字化。其中一个版本每秒记录的采样(sample)次数更多,两个版本每个采样使用的位数相同。

Which statement best describes the trade-off?以下哪项最恰当地描述了这种权衡?

Answer:答案: (D)
  • More frequent samples can represent the signal's changes over time more closely.
  • For a fixed duration and bits per sample, more samples require more bits.
Option A incorrectly promises exact reconstruction. Option B ignores the difference in sample counts. Option C confuses discrete digital representations with continuous analog signals.
  • 更频繁的采样可以更接近地表示信号随时间的变化。
  • 时长和每个采样的位数固定时,采样越多,需要的位数越多。
选项 A 错误地承诺一定能精确重建。选项 B 忽略了采样数量的差异。选项 C 混淆了离散的数字表示和连续的模拟信号。
Q4HARDAP MC2.2 Data Compression

A message has 7 consecutive A symbols, followed by 4 B symbols, 10 C symbols, and 3 D symbols. Its original representation uses 3 bits per symbol. A lossless scheme represents each consecutive run using 3 bits for the symbol and 5 bits for the run length. All four run lengths fit in 5 bits.一条消息由连续的 7 个 A、4 个 B、10 个 C 和 3 个 D 依次组成。原始表示中每个符号使用 3 位。一种无损压缩(lossless compression)方案用 3 位表示符号,再用 5 位表示该符号连续出现的次数。四段的长度均可用 5 位表示。

How many bits does this scheme use to represent the compressed message?该方案用多少位表示压缩后的消息?

Answer:答案: (B)
  • The message contains four runs.
  • Each run uses 3 + 5 = 8 bits, so the compressed message uses 4 × 8 = 32 bits.
Option A counts the symbols rather than the compressed bits. Option C counts 10 bits per run. Option D is the original size, 24 × 3 bits.
  • 消息共有四段连续的相同符号。
  • 每段使用 3 + 5 = 8 位,因此压缩后的消息使用 4 × 8 = 32 位。
选项 A 计算的是符号数量,而不是压缩后的位数。选项 C 错把每段算作 10 位。选项 D 是原始大小,即 24 × 3 位。
Q5MEDIUMAP MC2.2 Data Compression

A laboratory must store measurement files so that every original bit can be recovered later. Reducing file size is desirable but not as important as exact recovery.实验室需要存储测量文件,要求之后能恢复原文件的每一位。减小文件大小是可取的,但不如精确恢复重要。

Which approach best meets the requirement?哪种方法最符合要求?

Answer:答案: (C)
  • Lossless compression guarantees reconstruction of the original data.
  • It can reduce size without sacrificing the required exact recovery.
Option A may discard information. Option B changes the original file. Option D can change measurement values.
  • 无损压缩能保证重建原始数据。
  • 它可以在满足精确恢复要求的同时减小文件大小。
选项 A 可能丢弃信息。选项 B 改变了原始文件。选项 D 可能改变测量值。
Q6HARDAP MC2.2 Data Compression

A news service compares compression methods for photographs and documents.一家新闻机构正在比较用于照片和文档的压缩方法。

Which two statements are correct? Select two answers. Select two answers.以下哪两项说法正确?请选择两个答案。 选择两个答案。

Answer:答案: (A), (C)
  • Lossless compression can encode redundant data using fewer bits while allowing exact recovery, so A is correct.
  • Lossy compression can trade exact reconstruction for a smaller representation, so C is correct in the stated context.
Option B ignores differences among images and algorithms. Option D assumes discarded details can always be recovered.
  • 无损压缩可以用更少的位编码冗余数据,同时允许精确恢复,因此 A 正确。
  • 有损压缩可以用精确重建能力换取更小的表示,因此 C 在所述情境中正确。
选项 B 忽略了图像和算法之间的差异。选项 D 错误地认为丢弃的细节总能恢复。
Q7HARDAP MC2.3 Extracting Information from Data

A city finds that neighborhoods with more bicycle lanes also have lower average air pollution. The data do not include traffic volume or industrial activity.某市发现,自行车道较多的社区平均空气污染程度也较低。数据中不包含交通流量或工业活动情况。

Which conclusion is best supported by these data?这些数据最能支持以下哪项结论?

Answer:答案: (D)
  • The data show a correlation between lane availability and pollution.
  • Unmeasured factors, such as traffic and industry, could affect the relationship.
Option A treats correlation as proof of one causal direction. Option B asserts the reverse direction without evidence. Option C claims equality for a variable that was not measured.
  • 数据表明自行车道情况与污染程度之间存在相关性(correlation)。
  • 交通和工业等未测量的因素可能影响这一关系。
选项 A 把相关性当作某一因果方向的证明。选项 B 在没有证据的情况下断言了相反的因果方向。选项 C 断言一个未测量变量在各社区中相等。
Q8MEDIUMAP MC2.3 Extracting Information from Data

A photo organizer stores image pixels together with a creation date and camera model.一个照片管理程序将图像像素与创建日期和相机型号一起存储。

What can the creation date and camera model help the organizer do?创建日期和相机型号可以帮助该程序完成什么任务?

Answer:答案: (C)
  • The date and camera model are metadata describing the image.
  • They can be used as search and grouping criteria without examining the pixels.
Option A overstates what metadata establish. Option B assumes the date contains the pixel data. Option D confuses editing metadata with changing the primary image data.
  • 日期和相机型号是描述图像的元数据(metadata)。
  • 它们可以作为搜索和分组条件,无须检查像素。
选项 A 夸大了元数据能证明的内容。选项 B 错误地认为日期包含像素数据。选项 D 混淆了编辑元数据和改变图像的主要数据。
Q9HARDAP MC2.3 Extracting Information from Data

A transit agency wants to estimate satisfaction among all riders. Its current survey is available only through a smartphone app, and many riders do not use the app.一家交通机构想估计所有乘客的满意度。目前问卷只能通过智能手机应用填写,而许多乘客并不使用该应用。

Which change would best address the main limitation?哪项改变最有助于解决主要限制?

Answer:答案: (B)
  • The app-only collection method underrepresents riders who do not use the app.
  • Multiple accessible channels can reach a broader group, although careful sampling is still needed.
Option A can increase the amount of data without correcting the coverage bias. Option C introduces further bias. Option D changes precision but does not improve coverage.
  • 仅通过应用收集数据会使不使用应用的乘客代表性不足。
  • 多种可使用的渠道可以覆盖更广泛的人群,但仍需要谨慎抽样。
选项 A 可以增加数据量,却不一定能纠正覆盖偏差(coverage bias)。选项 C 会引入更多偏差。选项 D 改变了精度,却没有改善覆盖范围。
Q10HARDAP MC2.3 Extracting Information from Data

A school combines two attendance files. One uses the label "New York" and the other uses "NY" for the same city. Some records have missing student IDs, and different students can share a name.一所学校合并两份出勤文件。一份用“New York”,另一份用“NY”表示同一个城市。有些记录缺少学生 ID,且不同学生可能同名。

Which two actions are appropriate when preparing these data for analysis? Select two answers. Select two answers.准备分析这些数据时,哪两项操作是恰当的?请选择两个答案。 选择两个答案。

Answer:答案: (A), (C)
  • Standardizing equivalent labels makes the data uniform without changing their meaning, so A is correct.
  • Missing IDs make matches uncertain; flagging them preserves that uncertainty for investigation, so C is correct.
Option B can merge different students who share a name. Option D assigns unsupported identities to records.
  • 统一含义相同的标签可以使数据规范一致而不改变其含义,因此 A 正确。
  • 缺失 ID 会使匹配结果不确定,标记记录可以保留这一不确定性以供核查,因此 C 正确。
选项 B 可能合并同名的不同学生。选项 D 为记录指定了没有依据的身份。
Q11HARDAP MC2.4 Using Programs with Data

A program processes a list of measurements.一个程序处理测量值列表(list)。

values ← [4, 9, 0, 7, 6, 3]
total ← 0
count ← 0
FOR EACH value IN values {
  IF(value > 3 AND value MOD 2 = 0) {
    total ← total + value
    count ← count + 1
  }
}
DISPLAY(total)
DISPLAY(count)

What does the program display? The displayed values are separated by a space.程序显示什么?显示的值之间用空格分隔。

Answer:答案: (C)
  • The condition selects values greater than 3 that also have remainder 0 when divided by 2.
  • Only 4 and 6 qualify, giving total 10 and count 2.
Option A incorrectly counts 0 even though it is not greater than 3. Option B includes 9 despite its nonzero remainder. Option D sums all values greater than 3 without checking parity.
  • 条件选出大于 3 且除以 2 的余数为 0 的值。
  • 只有 4 和 6 符合条件,因此 total 为 10,count 为 2。
选项 A 错误地计入了不大于 3 的 0。选项 B 计入了余数不为 0 的 9。选项 D 将所有大于 3 的值相加,却没有检查奇偶性。
Q12HARDAP MC2.4 Using Programs with Data

A program removes missing-value markers, represented by 0, from a copy of a list.一个程序从列表的副本中删除用 0 表示的缺失值标记。

original ← [3, 0, 8, 0, 5]
clean ← original
i ← 1
REPEAT UNTIL(i > LENGTH(clean)) {
  IF(clean[i] = 0) {
    REMOVE(clean, i)
  } ELSE {
    i ← i + 1
  }
}
DISPLAY(original[2])
DISPLAY(LENGTH(clean))
DISPLAY(clean[2])

What does the program display? The displayed values are separated by spaces.程序显示什么?显示的值之间用空格分隔。

Answer:答案: (A)
  • Assigning original to clean makes a copy, so original[2] remains 0.
  • Each removal shifts the next value into the current position. The index advances only when no removal occurs.
  • The cleaned list is [3, 8, 5], so its length is 3 and its second element is 8.
Option B incorrectly treats the lists as aliases. Option C assumes a zero remains. Option D treats the first element as the second.
  • 将 original 赋给 clean 会创建副本,因此 original[2] 仍为 0。
  • 每次删除后,后面的值会移到当前位置;只有未删除时索引才增加。
  • 清理后的列表是 [3, 8, 5],长度为 3,第二个元素为 8。
选项 B 错误地认为两个列表共享同一份数据。选项 C 错误地认为仍有一个 0 留在列表中。选项 D 把第一个元素当成了第二个。
Q13HARDAP MC2.4 Using Programs with Data

Two lists contain corresponding daily records. The first list gives rainfall in centimeters, and the second gives the number of visitors on the same days.两个列表包含按日期一一对应的记录。第一个列表给出降雨量,单位为厘米;第二个列表给出同一天的访客人数。

rain ← [2, 0, 4, 1]
visitors ← [10, 20, 30, 40]
i ← 1
total ← 0
REPEAT UNTIL(i > LENGTH(rain)) {
  IF(rain[i] ≥ 2) {
    total ← total + visitors[i]
  }
  i ← i + 1
}
DISPLAY(total)

What does the program display?程序显示什么?

Answer:答案: (D)
  • The rainfall values meeting the condition occur at indices 1 and 3.
  • The corresponding visitor counts are 10 and 30, whose sum is 40.
Option A includes only the visitor count at index 3. Option B uses the counts at indices 2 and 4 instead. Option C sums visitors on every day.
  • 满足条件的降雨量位于索引 1 和索引 3。
  • 对应的访客人数为 10 和 30,合计 40。
选项 A 只计入了索引 3 的访客人数。选项 B 错误地使用了索引 2 和 4 的人数。选项 C 将所有日期的访客人数相加。
Q14HARDAP MC2.4 Using Programs with Data

A program examines consecutive measurements to count increases.一个程序检查相邻的测量值,并统计数值上升的次数。

readings ← [2, 5, 3, 6]
i ← 2
count ← 0
REPEAT UNTIL(i > LENGTH(readings)) {
  IF(readings[i] > readings[i - 1]) {
    count ← count + 1
  }
  i ← i + 1
}
DISPLAY(count)

What does the program display?程序显示什么?

Answer:答案: (B)
  • The comparisons are 5 > 2, 3 > 5, and 6 > 3.
  • The first and third comparisons are true, so count is 2.
Option A misses one increase. Option C counts every comparison regardless of its result. Option D counts the readings rather than the increases.
  • 程序依次比较 5 > 2、3 > 5 和 6 > 3。
  • 第一项和第三项比较为真,因此 count 为 2。
选项 A 漏掉了一次上升。选项 C 不论比较结果如何都计数。选项 D 统计的是测量值数量,而不是上升次数。
Q15HARDAP MC2.4 Using Programs with Data

A list uses negative values to mark invalid measurements. The procedure calculates the average of the remaining values. The list is guaranteed to contain at least one nonnegative value.一个列表用负值标记无效测量值。下面的过程计算其余值的平均值。已知列表中至少有一个非负值。

PROCEDURE validAverage(data) {
  total ← 0
  count ← 0
FOR EACH value IN data {
    IF(value ≥ 0) {
      total ← total + value
      count ← count + 1
    }
  }
  RETURN(total / count)
}
measurements ← [-1, 8, 0, 4, -1]
DISPLAY(validAverage(measurements))

What value does the program display?程序显示的值是多少?

Answer:答案: (A)
  • The nonnegative values are 8, 0, and 4, including 0.
  • Their sum is 12 and their count is 3, so the procedure returns 12 / 3 = 4.
Option B divides the valid sum by the full list length. Option C averages all five values, including the negative markers (10 / 5). Option D excludes the valid value 0 from the count.
  • 非负值为 8、0 和 4,其中包括 0。
  • 它们的和为 12,数量为 3,因此过程返回 12 / 3 = 4。
选项 B 用有效值之和除以整个列表的长度。选项 C 把包括负数标记在内的全部五个值取平均(10 / 5)。选项 D 在计数时排除了有效值 0。