# Set #1¶

The following questions make up Set #1 of the Practice Exam Questions. These questions are designed to be similar to those on the AP CSP exam. You should finish these questions within 17 minutes to stay on track with the timing of the actual exam. During the actual exam, you will be provided with the AP CS Reference Sheet, which can be found here.

Click the “Start” button when you are ready to begin the exam. Click the “Pause” button to pause the exam (you will not be able to see the questions when the exam is paused). It will show how much time you have used, but you have unlimited time. Click on the “Finish Exam” button at the end when you are done. The number correct, number wrong, and number skipped will be displayed at the bottom of the page. Feedback for each answer will also be shown as well as your answer.

You will not be able to change your answers after you hit the “Finish Exam” button.

24-1-1: Which of the following statements are true regarding compressing files?

1. If lossless compression is applied, every single bit of data that was originally in the file remains after the file is uncompressed.
2. No matter what compression technique is used, once a data file is compressed, it cannot be restored to its original state.
3. The amount of data reduction possible using lossy compression is often much higher than through lossless techniques.
• I. and III. only
• Correct. Statement I is true since it correctly identifies a property of lossless compression. Statement III is true becasue it correctly identifies the trade-offs involved in compression techniques.
• I. and II. only
• Incorrect. Statement II is false since lossless compression can be applied to restore a file to its original state.
• II. and III. only
• Incorrect. Statement II is false since lossless compression can be applied to restore a file to its original state.
• I., II. and III.
• Incorrect. Statement II is false since lossless compression can be applied to restore a file to its original state.
24-1-2: Which of the following statements about abstraction is true?
• Abstraction requires users to understand the low-level details of a system.
• Incorrect. Abstraction is used to hide the low-level details from the user, therefore this statement is false.
• Abstraction reduces information and detail to facilitate focus on relevant concepts.
• Correct. This follows from the definition of abstraction.
• Abstraction increases the run-time complexity of a program.
• Incorrect. Abstraction is not related to run-time complexity.
• Abstraction compresses a program file to reduce file size.
• Incorrect. Abstraction is not related to compression.

24-1-3: A programmer is writing code to switch the values of two integer variables, namely a and b, using a temporary integer variable, temp. This is the pseudo-code that the programmer has come up with:

temp ← a  # statement 1.
b ← temp  # statement 2.
a ← b     # statement 3.


Will the pseudo-code correctly perform the required task (assume that a and b are never numerically equal)?

• Yes, the code correctly switches the values of 'a' and 'b'.
• Incorrect. In this case, the value of 'a' will remain unchanged although 'b' will correctly store the value of 'a'.
• No, but it will work correctly if statements 1. and 3. are switched.
• Incorrect. In this case, the code will not compile as we are trying to assign the value of 'temp' to 'b' before giving a value to 'temp'.
• No, but it will work correctly if statements 2. and 3. are switched.
• Correct. Plug any values in 'a' and 'b' and trace the code! You will find that it works.
• No, but it will work correctly if statements 1. and 2. are switched.
• Incorrect. In this case, the code will not compile as we are trying to assign the value of 'temp' to 'b' before giving a value to 'temp'.

24-1-4: What is the final value of the integers X and Y after the following statements are executed?

X ← 15
Y ← 5
X ← X + Y
Y ← X + Y

• X = 155, Y = 1555
• Incorrect. Since 'X' and 'Y' are not strings, we cannot simply concatenate their characters.
• X = 20, Y = 20
• Incorrect. While the value of 'X' is correct in this answer choice, the final value of 'Y' is not.
• X = 15, Y = 5
• Incorrect. The values of both 'X' and 'Y' are incorrect in this answer choice.
• X = 20, Y = 25
• Correct. Trace the code! Don't forget to use the updated value of 'X' while finding the value of 'Y' in the last statement.

24-1-5: A user’s smartphone makes a request to a server for 4 packets that represent the image of a baby duck. The server sends the 4 packets but they arrive at the user’s smartphone out of order. How does the smartphone interpret the packets that form the image?

• The baby duck picture appears as intended.
• Correct. One of the specific design goals of TCP/IP network protocols is to allow packets to arrive out of order and then be reassembled correctly, therefore the picture appears as intended.
• The baby duck picture appears as 4 out of order images.
• Incorrect. The packets are always reassembled in the correct order, so the original picture will appear as inteded.
• The baby duck picture is distorted.
• Incorrect. The packets are always reassembled in the correct order, so the original picture will appear as inteded.
• The baby duck picture won’t load on the user’s smartphone.
• Incorrect. The picture will load since all the packets successfully arrive on the user's smart phone.
24-1-6: Which of the following technologies allows its users to store, manage and access files remotely over the Internet?
• Cloud Computing
• Correct. Storage solutions made possible by Cloud Computing allow users to store, manage and access files remotely over the Internet.
• Global Positioning System
• Incorrect. GPS allows navigation and location services to function, but it is not related to managing files remotely. Also note that GPS is not an Internet-dependent technology.
• Short Message Service
• Incorrect. SMS allows users to send text messages to one another using standardized communication protocols, but it's not related to managing files remotely. Also note that SMS is not an Internet-dependent technology.
• Data Mining
• Incorrect. Data Mining involves extracting and finding patterns in large data sets, but it's not related to managing files remotely. Also note that Data Mining can be done without the use of Internet.

24-1-7: Consider the following incomplete pseudo-code to print the largest of three integer variables, namely a, b and c:

IF (a ≥ b)
{
IF (<MISSING CODE 1>)
{
DISPLAY(a)
}
ELSE
{
DISPLAY(c)
}
}
ELSE
{
IF (<MISSING CODE 2>)
{
DISPLAY(c)
}
ELSE
{
DISPLAY(b)
}
}


Which of the following options can be substituted for <MISSING CODE 1> and <MISSING CODE 2>, respectively, for the code to work as intended?

• a ≥ c and c ≥ b
• Correct. Plug-in values for 'a', 'b' and 'c', then trace the code!
• a ≥ c and b ≥ c
• Incorrect. The second part of this answer choice is incorrect since we display 'c' even though 'b ≥ c'.
• c ≥ a and c ≥ b
• Incorrect. The first part of this answer choice is incorrect since we display 'a' even though 'c ≥ a'.
• c ≥ b and c ≥ a
• Incorrect. Both parts of this answer choice are incorrect, plug-in values for 'a', 'b' and 'c' to see for yourself.

24-1-8: Trace the value of an integer variable n in the following code.

i ← 1
n ← 2
REPEAT until i = 4
{
n ← n * 2
i ← i + 1
}


What is the value of n after the above code executes?

• 4
• Incorrect. This would be true if the loop terminated at i = 2
• 8
• Incorrect. This would be true if the loop terminated at i = 3
• 16
• Correct. This is true since the loop runs 3 times and we are multiplying 'n' with 2 in each iteration.
• 32
• Incorrect. This would be true if the loop terminated at i = 5

24-1-9: A professor uses an automated computer system to manage the student records of his classes. The time the system takes to perform various tasks for different class sizes is shown in the table below:

Task ↓ Size → Small class (25 students) Medium class (50 students) Large class (100 students)
Sorting students by grade 10 seconds 40 seconds 160 seconds
Deleting a student’s record 2 seconds 4 seconds 8 seconds
Searching for a student’s name 1 second 2 seconds 4 seconds
Adding bonus points to grades of all students 3 seconds 6 seconds 9 seconds

Based on the information in the table, which of the following tasks is likely to take the least amount of time if the computer system is used for a class of 400 students?

• Incorrect. Since the run-time quadruples whenever the number of students in class double, the run-time for a class of 400 students would be 2560 seconds.
• Deleting a student’s record
• Incorrect. Since the run-time doubles whenever the number of students in class double, the run-time for a class of 400 students would be 32 seconds.
• Searching for a student’s name
• Incorrect. Since the run-time doubles whenever the number of students in class double, the run-time for a class of 400 students would be 16 seconds.