# Set #3¶

The following questions make up Set #3 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-3-1: Which of the following would be a subdomain of the domain sample.org according to the guidelines of the Domain Name System (DNS)?
• sample.com
• Incorrect. This is a completely different website unrelated to sample.org.
• sample.org.biz
• Incorrect. sample.org is a subdomain of biz in this answer choice.
• enter.sample.org
• Correct. The subdomain is always on the left of the domain name.
• sample.org/help
• Incorrect. Subdomains are always on the left side of the domain and use a "." instead of a "/".

24-3-2: There are 16 students standing in a classroom. Each student is given back his or her graded homework. Students decide to find out the class’s average score on the homework. Two different algorithms are given for finding the average score.

Algorithm A
Step 1: All students stand.
Step 2: A randomly selected student writes his or her score on the whiteboard
and is seated.
Step 3: A randomly selected standing student adds his or her score to the value
on the whiteboard, records the new value on the whiteboard, and is seated.
The previous value on the whiteboard is erased.
Step 4: Repeat step 3 until no students remain standing.
Step 5: The value on the whiteboard is divided by 16.

Algorithm B
Step 1: All students stand.
Step 2: Students form groups of 4.
Step 3: In each group, the students with the lowest and highest scores return
to their seats.
Step 4: Repeat steps 1 and 2 until only two students remain standing.
Step 5: Add the remaining two students’ numbers and divide the sum by two.


Which of the following statements is true?

• Algorithm A always calculates the correct average, but Algorithm B may not.
• Correct. Algorithm A correctly calculates the average, while Algorithm B does not.
• Algorithm B always calculates the correct average, but Algorithm A may not.
• Incorrect. Algorithm B would calculate the average if the groups of four took an average of their scores.
• Both Algorithm A and Algorithm B always calculate the correct average.
• Incorrect. Algorithm B would calculate the average if the groups of four took an average of their scores.
• Neither Algorithm A nor Algorithm B always calculate the correct average.
• Incorrect. Algorithm A correctly calculates the average.

24-3-3: Meteorologists record atmospheric data to predict future weather conditions. Suppose that a meteorological lab in Atlanta takes hourly measurements of air temperature and precipitation in the city for a total period of 12 months. Note that the lab also records the exact time and date for each measurement.

Which of the following questions about the city’s weather could NOT be accurately answered using only the data collected by the lab?

• How does the temperature fluctuate from day to night?
• Incorrect. The meteorologists have temperature data from days and nights so they can compare the differences between them.
• Is there a correlation between air temperature and precipitation?
• Incorrect. The meteorologists have temperature and precipitation data, so they can compare them and determine if there is a correlation.
• What is the average annual precipitation?
• Correct. The meteorologists only have data from one year, so they cannot calculate the average annual precipitation.
• What is the average daily temperature?
• Incorrect. The meteorologists have temperature data for an entire year, so they can find the average of daily temperatures across that time range.

24-3-4: Meteorologists record atmospheric data to predict future weather conditions. Suppose that a meteorological lab in Atlanta takes hourly measurements of air temperature and precipitation in the city for a total period of 12 months. Note that the lab also records the exact time and date for each measurement.

Which of the following questions about Atlanta’s weather can be accurately answered using only the data collected by the lab?

• How does wind speed fluctuate from day to night?
• Incorrect. The meteorologists do not have wind speed data.
• During which hour of the day does it rain the most on average?
• Correct. The meteorologists have precipitation data for a year, so they can calculate this.
• Is there a correlation between air pressure and precipitation?
• Incorrect. The meteorologists do not have air pressure data.
• Is there a correlation between Atlanta’s temperature and Chicago’s temperature?
• Incorrect. The meteorologists do not have data for Chicago's temperature.
24-3-5: ASCII is a character-encoding scheme that uses numeric values in decimal (base 10) to represent alphanumeric and special characters. For example, the uppercase letter ‘A’ is represented by the decimal value ‘65’. Digits from ‘0’ - ‘9’ also have a corresponding ASCII value. The digit ‘0’ has an ASCII value of ‘48’, ‘1’ has an ASCII value of ‘49’ and so on.We can represent the ASCII value of digits as hexadecimal numbers (base 16) as well. Which digit has a hexadecimal value of ‘33’?
• 8
• Incorrect. This would be true for a hexadecimal value of 38.
• 7
• Incorrect. This would be true for a hexadecimal value of 37.
• 5
• Incorrect. This would be true for a hexadecimal value of 35.
• 3
• Correct. The ASCII value would be '51'.
24-3-6: Imagine there is a programming language which uses two different data types to store integers - a 16-bit short data type and a 64-bit long data type. Then which of the following statements is true about the two data types?
• The long data type can store 2^48 times as many distinct values as the short data type
• Correct. It can store 2^(64 - 16) as many distinct values.
• The long data type can store 2^64 times as many distinct values as the short data type
• Incorrect. That is how many total values the long data stores.
• The long data type can store 2^16 times as many distinct values as the short data type
• Incorrect. That is how many total values the short data stores.
• The short data type can store 4 times as many distinct values as the long data type
• Incorrect. While long data is 4 times as long as the short, the question asks for the difference in distinct values the data type can hold.

24-3-7: At a company, n number of employees are given the same bonus of $5,000 on top of their salary. However, each person can only get a maximum of$100,000 a year, so if adding the bonus causes the employee’s total pay to surpass $100,000, the employee will receive the maximum pay of$100,000. Each employee’s original annual salary is stored in a list entitled employeeList, indexed from 1 to n.

PROCEDURE addBonuses(employeeList)
{
i ← n
REPEAT n TIMES
{
<MISSING CODE>
i ← i + 1
}
RETURN employeeList
}


Which of the following code segments can be placed in the <MISSING CODE> area to make the program work as expected?

(The min(a,b) and max(a,b) functions return the lesser and greater values of the inputs, respectively.)

Option I.

employeeList[i] ← min (employeeList [i] + 5000, 100000)


Option II.

employeeList [i] ← max (employeeList [i] + 5000, 100000)


Option III.

employeeList[i] ← employeeList [i] + 5000
IF (employeeList [i] > 100000)
{
employeeList [i] ← employeeList [i] - 5000
}


Option IV.

employeeList[i] ← employeeList [i] + 5000
IF (employeeList [i] > 100000)
{
employeeList [i] ← 100000
}

• I,III
• Incorrect. Option III will not give them the maximum pay, and won't give them any bonus.
• II, III
• Incorrect. Both of these options are incorrect.
• I, IV
• Correct. Both of these options correctly calculate each employee's pay.
• I, II, III, IV
• Incorrect. Options II and III both incorrectly calculate the employee's pay.

24-3-8: Which of the following have increased the availability of communication and collaboration between people at a distance?

I. Social Media
II. SMS
III. Email
IV. Video Conferencing
• I, IV
• Incorrect. SMS and Email have also increased the availability of distant communication and collaboration.
• I, III, IV
• Incorrect. SMS has also increased the availability of distant communication and collaboration.
• II, III
• Incorrect. Social Media websites and Video Conferencing have also increased the availability of distant communication and collaboration.
• I, II, III, IV
• Correct. All of these utilities have increased the availability of distant communication and collaboration.

24-3-9: Which of the following statements are true about algorithms?

I. If an algorithm runs in reasonable time, the number of steps the algorithm takes is a polynomial function (constant, linear, squared, etc.) of the size of the input.
II. All problems can be solved using an algorithm that runs in reasonable time.
III. If a problem cannot be solved in reasonable time, a heuristic approach is helpful to solve the problem.
• I, II
• Incorrect. Option II is incorrect. Some problems require algorithms that do not run in reasonable time.
• I, III
• Correct. Both of these statements regarding algorithms are true.
• I, II, III
• Incorrect. Option II is incorrect. Some problems require algorithms that do not run in reasonable time.
• None of the options
• Incorrect. An algorithm that runs in reasonable time refers to a polynomial function of the input size.

24-3-10: The red triangle in the grid below is currently located at the position (5, 1) (5th row down and 1st column across), and is facing upward.

If the following code is run, which position will the red triangle end up on?

n ← 4
REPEAT UNTIL n = 1
{
REPEAT n TIMES
{
MOVE_FORWARD
}
TURN_RIGHT
n ← n/2
}

• (3,3)
• Incorrect. Notice that n is changed to n/2 after the inner loop.
• (1,3)
• Correct. By following the code, you can see that the triangle ends up in (1,3).
• (5,3)
• Incorrect. The triangle only turns right throughout the enter code segment.
• (1,1)
• Incorrect. Did you miss the TURN_RIGHT call after the inner loop?
Next Section - Set #4