You are on page 1of 9

AP COMPUTER SCIENCE PRINCIPLES Scoring Guide

Day 7 Quiz

1. In the following procedure, the parameter age represents a person’s age. The procedure is intended to return the
name of the age group associated with age. People who are under 18 are considered minors, people who are 65
and older are considered senior citizens, and all other people are considered adults. The procedure does not work as
intended.

Line 1: PROCEDURE ageGroup(age)


Line 2: {
Line 3: result "adult"
Line 4: IF(age ≥ 65)
Line 5: {
Line 6: result "senior citizen"
Line 7: }
Line 8: RETURN(result)
Line 9:
Line 10: result "adult"
Line 11: IF(age < 18)
Line 12: {
Line 13: result "minor"
Line 14: }
Line 15: RETURN(result)
Line 16: }

Removing which two lines of code will cause the procedure to work as intended?

Select two answers.

A Line 3

B Line 8

C Line 10

D Line 15

2. To be eligible for a particular ride at an amusement park, a person must be at least 12 years old and must be
between 50 and 80 inches tall, inclusive.

Let age represent a person’s age, in years, and let height represent the person’s height, in inches. Which of
the following expressions evaluates to true if and only if the person is eligible for the ride?

(A) (age ≥ 12) AND ((height ≥ 50) AND (height ≤ 80))


(B) (age ≥ 12) AND ((height ≤ 50) AND (height ≥ 80))
(C) (age ≥ 12) AND ((height ≤ 50) OR (height ≥ 80))
(D) (age ≥ 12) OR ((height ≥ 50) AND (height ≤ 80))

AP Computer Science Principles Page 1 of 9


Scoring Guide

Day 7 Quiz

3. A company delivers packages by truck and would like to minimize the length of the route that each driver must
travel in order to reach delivery locations. The company is considering two different algorithms for determining
delivery routes.

Algorithm I all possible routes, compute their lengths, and then select the shortest possible route. This
Generate
algorithm does not run in reasonable time.
Algorithm II from an arbitrary delivery location, find the nearest unvisited delivery location. Continue
Starting
creating the route by selecting the nearest unvisited location until all locations have been visited.
This algorithm does not guarantee the shortest possible route and runs in time proportional to .

Which of the following best categorizes algorithm II?


(A) Algorithm II attempts to use an algorithmic approach to solve an otherwise undecidable problem.
(B) Algorithm II uses a heuristic approach to provide an approximate solution in reasonable time.
Algorithm II provides no improvement over algorithm I because neither algorithm runs in reasonable
(C)
time.
(D) Algorithm II requires a much faster computer in order to provide any improvement over algorithm I.

4. A graphic artist uses a program to draw geometric shapes in a given pattern. The program uses an algorithm that
draws the shapes based on input from the artist. The table shows the approximate number of steps the algorithm
takes to draw different numbers of shapes.

Number of Number of

Shapes Drawn Steps

4 17
5 24
6 35
7 50

Based on the values in the table, which of the following best characterizes the algorithm for drawing shapes,
where is a very large number?

Page 2 of 9 AP Computer Science Principles


Scoring Guide

Day 7 Quiz

The algorithm runs in a reasonable amount of time because it will use approximately steps to draw
(A)
shapes.
The algorithm runs in a reasonable amount of time because it will use approximately steps to draw
(B)
shapes.
The algorithm runs in an unreasonable amount of time because it will use approximately steps to draw
(C)
shapes.
The algorithm runs in an unreasonable amount of time because it will use approximately steps to
(D)
draw shapes.

5. A local router is configured to limit the bandwidth of guest users connecting to the Internet. Which of the following
best explains the result of this configuration as compared to a configuration in which the router does not limit the
bandwidth?
(A) The amount of time it takes guest users to send and receive large files is likely to decrease.
(B) The number of packets required for guest users to send and receive data is likely to decrease.
(C) Guest users will be prevented from having fault-tolerant routing on the Internet.
(D) Guest users will be restricted in the maximum amount of data that they can send and receive per second.

6. Let n be an integer value. Which of the following expressions evaluates to true if and only if n is a two-digit
integer (i.e., in the range from 10 to 99, inclusive)?
(A) n = (n MOD 100)
(B) (n ≥ 10) AND (n < 100)
(C) (n < 10) AND (n ≥ 100)
(D) (n > 10) AND (n < 99)

7. To attend a particular camp, a student must be either at least 13 years old or in grade 9 or higher, but must not yet be
18 years old. Let age represent a student’s age and let grade represent the student’s grade level. Which of the
following expressions evaluates to true if the student is eligible to attend the camp and evaluates to false
otherwise?
(A) ((age ≥ 13) OR (grade ≥ 9)) AND (age ≤ 18)
(B) ((age ≥ 13) OR (grade ≥ 9)) AND (age < 18)
(C) ((age ≥ 13) OR (grade ≥ 9)) OR (age ≤ 18)
(D) ((age ≥ 13) OR (grade ≥ 9)) OR (age < 18)

8. Which of the following best explains why it is not possible to use computers to solve every problem?
(A) Current computer processing capabilities cannot improve significantly.
Large-scale problems require a crowdsourcing model, which is limited by the number of people
(B)
available to work on the problem.
The ability of a computer to solve a problem is limited by the bandwidth of the computer’s Internet
(C)
connection.
(D) There exist some problems that cannot be solved using any algorithm.

AP Computer Science Principles Page 3 of 9


Scoring Guide

Day 7 Quiz

9. Directions: The question or incomplete statement below is followed by four suggested answers or
completions. Select the one that is best in each case.

Which of the following is an example of symmetric encryption?


Evy buys a locked box that operates using two different codes. When the first code is entered, a slot
opens that allows a message to be put in the box. When the second code is entered, the door to the box
(A)
opens. Evy gives the first code to her friends so they can leave messages for her and keeps the second
code to herself so that she is the only one who can retrieve the messages.
Finn and Gwen develop a system that maps each letter of the alphabet to a unique symbol using a secret
(B) key. Finn uses the key to write a message to Gwen where each letter is replaced with the corresponding
symbol. Gwen uses the key to map each symbol back to the original letter.
Hannah writes a message to send to Isabel and hides the message under a rock behind the soccer field.
(C)
Hannah gives Isabel the exact location of the rock so that only Isabel can find the message.
Juan writes a message to send to Kelly and slides the message through a slot in the front of Kelly’s
(D) locker. Juan knows that Kelly has not shared her locker combination with anyone, so no one other than
Kelly will be able to read the message.

10. A Web site uses several strategies to prevent unauthorized individuals from accessing user accounts. Which of the
following is NOT an example of multifactor authentication?
Each employee for a company is issued a USB device that contains a unique token code. To log into a
(A) company computer, an employee must insert the USB device into the computer and provide a correct
password.
After logging into an account from a new device, a user must enter a code that is sent via e-mail to the e-
(B)
mail address on file with the account.
In order to log into an account, a user must provide both a password and a fingerprint that is captured
(C)
using the user’s device.
When a user enters an incorrect password more than two times in a row, the user is locked out of the
(D)
account for 24 hours.

Page 4 of 9 AP Computer Science Principles


Scoring Guide

Day 7 Quiz

11. The following procedure is intended to return the value of x times y, where x and y are integers.
Multiplication is implemented using repeated additions.

For which of the following procedure calls does the procedure NOT return the intended value?

Select two answers.

AP Computer Science Principles Page 5 of 9


Scoring Guide

Day 7 Quiz

12. A student wrote the following program to remove all occurrences of the strings "the" and "a" from the list
wordList.

Line 1: index LENGTH (wordList)


Line 2: REPEAT UNTIL (index < 1)
Line 3: {
Line 4: IF ((wordList[index] = "the") OR (wordList[index] = "a"))
Line 5: {
Line 6: REMOVE (wordList, index)
Line 7: }
Line 8: }

While debugging the program, the student realizes that the loop never terminates. Which of the following changes
can be made so that the program works as intended?
(A) Inserting index index + 1 between lines 6 and 7
(B) Inserting index index + 1 between lines 7 and 8
(C) Inserting index index - 1 between lines 6 and 7

(D) Inserting index index - 1 between lines 7 and 8

13. The following code segment is intended to remove all duplicate elements in the list myList. The procedure does
not work as intended.

j LENGTH(myList)
REPEAT UNTIL(j = 1)
{
IF(myList[j] = myList[j - 1])
{
REMOVE(myList, j)
}
j ← j - 1
}

For which of the following contents of myList will the procedure NOT produce the intended results?

Select two answers.

A [10, 10, 20, 20, 10, 10]

B [30, 30, 30, 10, 20, 20]

C [30, 50, 40, 10, 20, 40]

D [50, 50, 50, 50, 50, 50]

Page 6 of 9 AP Computer Science Principles


Scoring Guide

Day 7 Quiz

14. The procedure Draw (length, direction) is used to draw a line segment length units long in a given direction (left,
right, up, or down), starting at the current cursor position. The cursor is then repositioned at the end of the line
segment that was drawn. Consider the following program, where the cursor starts in the upper left corner of a grid
of dots. The dots are spaced one unit apart.

Draw (1, right)

Draw (2, down)

Draw (1, left)

Draw (1, right)

Draw (1, up)

Draw (1, left)

Which of the following represents the figure that is drawn by the program?

(A)

(B)

(C)

(D)

AP Computer Science Principles Page 7 of 9


Scoring Guide

Day 7 Quiz

15. Consider the following procedure.

Procedure Call Explanation


DrawLine (x1, y1, Draws a line segment on a coordinate grid with endpoints at coordinates
x2, y2) (x1, y1) and (x2, y2)

The DrawLine procedure is to be used to draw the following figure on a coordinate grid.

The following code segment is intended to draw the figure.

startX 2
startY 6
endX 8
endY 8
REPEAT 4 TIMES
{
<MISSING CODE>
}

Which of the following can be used to replace <MISSING CODE> so that the figure is drawn correctly?

Page 8 of 9 AP Computer Science Principles


Scoring Guide

Day 7 Quiz

DrawLine (startX, startY, endX, endY)


(A) endY endY - 2
DrawLine (startX, startY, endX, endY)
(B) endX endX - 2
endY endY - 2
endY endY - 2
(C) DrawLine (startX, startY, endX, endY)

endX endX - 2
(D) endY endY - 2
DrawLine (startX, startY, endX, endY)

AP Computer Science Principles Page 9 of 9

You might also like