Back to Challenge Set 14

Question Set 7

Difficulty  

divider

What This Is

Six exam-style questions, mostly about walking through an array — Activities 1.25 and 1.26. These sets are cumulative, so conditions, loops, arithmetic, and Part 0 are all still fair game. This is the last set before the quarter review.

Questions 2 and 3 are a pair: the same scores, the same loop starting at 1, two different answers. One of them is a bug and one of them is correct.

How to Do This One

  • Set a timer for 10 minutes before you start — the same as Question Set 6.
  • When the timer ends, stop. Mark anything unfinished as unfinished — that is real information, not a failure.
  • Work them out. Do not run the code. On exam day there is no computer.
  • For each question, also write sure or unsure. This is graded on completion, so an honest unsure costs you nothing and tells us both where to look.

Guessing beats leaving it blank. There is no penalty for a wrong answer on the AP exam, so a blank is a guaranteed zero where a guess is not.


The Questions

Four have exactly one correct answer, one asks you to select all that apply, and the last is about data or the impact of computing rather than about code.


Question 1

The following is written in AP exam notation. What does it display?

Question 1
nums ← [4, 7, 2]
FOR EACH n IN nums
{
DISPLAY(n * 2)
}
  1. 8 14 4
  2. 4 7 2
  3. 13
  4. 26

Question 2

What does the following C# display?

Question 2
int[] scores = { 7, 3, 9 };
int total = 0;
for (int i = 1; i < scores.Length; i++)
{
total = total + scores[i];
}
Console.WriteLine(total);
  1. 19
  2. 12
  3. 16
  4. Nothing — the program stops with an exception

Question 3

The following is written in AP exam notation. What does it display?

Question 3
scores ← [7, 3, 9]
total ← 0
i ← 1
REPEAT LENGTH(scores) TIMES
{
total ← total + scores[i]
i ← i + 1
}
DISPLAY(total)
  1. 19
  2. 12
  3. 16
  4. An error, because scores[3] is past the end of the list

Question 4

Two arrays hold the positions of three invaders, the way Raylib Lab 6 did. What happens when the following C# runs?

Question 4
int[] xs = { 100, 200, 300 };
int[] ys = { 50, 60 };
for (int i = 0; i < xs.Length; i++)
{
Console.WriteLine($"{xs[i]} {ys[i]}");
}
Console.WriteLine("Done");
  1. It displays three lines, the last one 300 0, then Done
  2. It displays two lines, then stops with an IndexOutOfRangeException, and Done is never displayed
  3. It displays two lines, skips the third, then displays Done
  4. Nothing — it will not compile, because the arrays are different lengths

Question 5 — Select all that apply

Which of these visit every element of aList in AP exam notation?

  1. FOR EACH item IN aList
  2. i ← 1, then REPEAT LENGTH(aList) TIMES, with i ← i + 1 as the last line inside the loop
  3. for (int i = 0; i < aList.Length; i++)
  4. i ← 1, then REPEAT UNTIL(i > LENGTH(aList)), with i ← i + 1 as the last line inside the loop
  5. i ← 0, then REPEAT LENGTH(aList) TIMES, with i ← i + 1 as the last line inside the loop

Question 6 — Data and Impact

A mapping project asks thousands of volunteers to each trace a few roads from satellite images. This is an example of:

  • (A) Compression
  • (B) Metadata
  • (C) The digital divide
  • (D) Crowdsourcing

Submit

  • Your answer to each question, with sure or unsure
  • Whether you finished inside 10 minutes, and if not, how far you got
  • One sentence: which question took you longest, and what slowed you down?

This is graded on completion, not accuracy. A thoughtful wrong answer earns the same as a right one. What is being built here is speed and stamina, and both require being allowed to get things wrong cheaply.

Start the Timer