Font size
WorksheetsAPCSP Q2 Exam
Total questions: 75
Worksheet time: 2hrs 53mins
Convert 0011 1111 to decimal
32
31
64
63
An Internet attack that causes a server to crash by making repeated requests to the same IP address:
DDoS (Distributed Denial of Service)
Cache Poisoning
DNS (Domain Name System) Hijacking
Phishing
The protocol that determines how to address nodes on the network (with IP addresses) and how to route data from one node to a destination node (using routers).
TCP (Transmission Control Protocol)
UDP (User Datagram Protocol)
IP (Internet Protocol)
HTTP (Hypertext Transfer Protocol)
I - Lossless compression is used only to send files over the Internet
II - Sending a compressed version of a file ensures that the contents of the file cannot be intercepted by an unauthorized user.
Which of the following questions can NOT be answered using only the data and metadata collected?
PROCEDURE MoveTriangle (numMoves, numTurns)Which of the following instructions will get the red triangle to the gray square?
{
REPEAT numMoves TIMES
{
MOVE_FORWARD()
}
REPEAT numTurns TIMES
{
TURN_RIGHT()
}
}
MoveTriangle (1, 1) MoveTriangle (1, 1) MoveTriangle (3, 1) MoveTriangle (3, 0)
MoveTriangle (4, 1)
MoveTriangle (4, 0)
MoveTriangle (1, 1)
MoveTriangle (1, 3)
MoveTriangle (3, 1)
MoveTriangle (3, 0)
MoveTriangle (1, 1)
MoveTriangle (1, 3)
MoveTriangle (3, 3)
MoveTriangle (3, 0)
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.
a and b, using a temporary integer variable, temp. Will the pseudo-code correctly perform the required task (assume that a and b are never numerically equal)?This is the pseudo-code that the programmer has come up with:
temp ← a # statement 1.
b ← temp # statement 2.
a ← b # statement 3.
Trace the value of an integer variableWhat is n?nin the following code.
i ← 1
n ← 2
REPEAT until i = 4
{
n ← n * 2
i ← i + 1
}
Which of the following conditional statements will allow the code to function as expected?
I. temp == 0
II. temp > 0
III. temp < 0
IV. NOT (temp >= 0)
PROCEDURE incrementTemperature(temp)
{
IF (<MISSING CODE>)
{
temp ← temp + 1
}
RETURN temp
}
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.
What number does 110 represent in binary?
6
3
8
12
What is the minimum number of bits you would need to encode the 26 letters of the alphabet plus a space – a total of 27 characters?
7 BITS
6 BITS
5 BITS
4 BITS
A video-streaming Web site uses 32-bit integers to count the number of times each video has been played. In anticipation of some videos being played m ore times than can be represented with 32 bits, the Web site is planning to change to 64-bit integers for the counter. Which of the following best describes the result of using 64-bit integers instead of 32-bit integers?
2 times as many values can be represented
32 times as many values can be represented
2^32 times as many values can be represented
32^2 times as many values can be represented
A programmer completes the user manual for a video game she has developed and realizes she has reversed the roles of goats and sheep throughout the text. Consider the programmer’s goal of changing all occurrences of “goats” to “sheep” and all occurrences of “sheep” to “goats”. The programmer will use the fact that the word “foxes” does not appear anywhere in the original text.
Which of the following algorithms can be used to accomplish the programmer’s goal?
First, change all occurrences of “goats” to “sheep”
Then, change all occurrences of “sheep” to “goats”
First, change all occurrences of “goats” to “sheep”
Then, change all occurrences of “sheep” to “goats”
Last, change all occurrences of “foxes” to “sheep”
First, change all occurrences of “goats” to “foxes”
Then, change all occurrences of “sheep” to “goats”
Last, change all occurrences of “foxes” to “sheep”
First, change all occurrences of “goats” to “foxes”
Then, change all occurrences of “foxes” to “sheep”
Last, change all occurrences of “sheep” to “goats”
Which of the following statements are true about routers and routing on the Internet? (Choose two)
Protocols ensure that a single path between two computers is established before sending packets over it
Routers are hierarchical and the “root” router is responsible for communicating to sub-routers the best paths for them to route internet traffic
A packet traveling between two computers on the Internet may be routed many times along the way or even lost or “dropped”
Routers act independently and route packets as they see fit
From the list provided choose the two (2) answers that correctly describe which Internet protocol relies on the other. For example: if protocol A relies on protocol B, it means that A is a higher level protocol than B, and thus protocol B must exist and work properly in order for protocol A to do its job.
TCP/IP relies on HTTP
HTTP relies on TCP/IP
DNS relies on TCP/IP
TCP/IP relies on DNS
The following question uses a robot in a grid of squares. The robot is represented as a triangle, which is initially in the bottom left square of the grid and facing right.
Consider the code segment, which moves the robot in the grid.
Which of the following shows the location of the robot after running the code segment
when a cellular telephone user places a call. The carrier transmits the caller's voice as well as the voice of the person who is called. The encoded voices are the data of the call. In addition to transmitting the data, the carrier also stores metadata. The metadata of the call include information such as the time the call is placed and the phone numbers of both participants. For which of the following goals would it be more useful to computationally analyze the metadata instead of the data?
I. To determine if a caller frequently uses a specific word
II. To estimate the number of phone calls that will be placed next Monday between 10:30 AM and noon.
III To generate a list of criminal suspects when given the telephone number of a known criminal.
I only
II only
II and III only
I, II, and III
Which of the following is least likely to indicate a phishing attack?
An email from your bank asks you to call the number on your card to verify a transaction.
An email from a merchant asks that you click on a link to reset your password.
An email from a utility company asks you to enter your date of birth and social security number for verification purposes.
An email that indicates you have won a large sum of money and asks you to enter your bank account number so that money can be transferred to you.
In public key cryptography, the sender uses the recipient's public key to encrypt a message. Which of the following is needed to decrypt the message?
The sender's public key
The sender's private key
The recipient's public key
The recipient's private key
What are brute-force attacks?
Attacks that use frequency analysis to break passwords
Attacks that check each possible solution to break encrypted data
Attacks against DNS servers to enable DDOS attacks
Attacks on firewalls to gain access to a company's sensitive data
What is a symmetric key used for?
Sending and receiving information from the web
Encrypting data
Decrypting data
Encrypting and decrypting data
What is 20 MOD 15?
0
5
15
20
When a computer scientist uses the term "Big Data" what do they typically mean?
That a dataset is larger than 5TB which is the common "Big Data" threshold.
That there is so much data it's virtually impossible to process.
There is enough data that traditional data processing applications are inadequate.
It implies that the findings from the data are potentially hugely important for society.
Approximately how much bigger (how many more bytes) is a megabyte than a kilobyte?
1,000 times bigger
100,000 times bigger
1,000,000 times bigger
1,000,000,000 times bigger
Which of the following is a reason to use lossy compression?
You want the compressed file to be larger than the original.
You want the highest quality audio file possible, with no modifications.
You want the highest quality image file possible, with no modifications.
You want to save space and are not concerned if the file is the highest quality possible.
How many bits are needed to represent 8 colors?
8 bits
24 bits
1 hex digit
3 bits
The color widget uses 3 bytes of metadata. The first two bytes indicate the width and height of the image. The next byte indicates the number of bits that will be used to represent color. How many bits is used to represent color given the metadata (in binary) 00001000 00001000 0001001
3 bits
6 bits
9 bits
12 bits
Consider the following three binary numbers:
01010
010000
1110
Which of the following lists the numbers in order from least to greatest?
010000
1110
01010
01010
1110
010000
01010
010000
1110
1110
01010
010000
A raw digital sound file samples a sound wave at some interval and measures the height of the wave at each point. Thus, raw sound is recorded as a list of numbers.
In very broad terms the MP3 audio compression algorithm identifies frequencies and volume levels - low and high - that are outside the range of human hearing and removes the data representing these frequencies from the original. This technique results in a smaller audio file that sounds exactly the same to the human ear.
This technique is an example of what type of compression?
Lossy compression
Lossless compression
Fast Fourier Transform compression
Tailored compression
A program contains a 2D array ("CUSTOMER") storing customer numbers, first names and surnames
What data is held in stored in CUSTOMER (2,3)?
Amrit
Kahn
Taylor
1003
Choose 1 answer:
REPEAT 2 TIMES
{
walkForward()
turnRight()
walkForward()
turnRight()
}
REPEAT 2 TIMES
{
walkForward()
turnRight()
walkForward()
turnLeft()
turnLeft()
}
REPEAT 2 TIMES
{
walkForward()
turnRight()
walkForward()
turnLeft()
}
REPEAT 2 TIMES
{
walkForward()
turnLeft()
walkForward()
turnRight()
}
An algorithm will be used to calculate the difference between the smallest and largest values in a list. For the list of [10, 3, 5, 6], it should calculate a difference of 7.
There are two proposals for the algorithm:
Algorithm 1: Set minVal to the first value in the list and maxVal to the last value in the list. Iterate through each number in the list. If the number is greater than maxVal, store it in maxVal. If the number is less than minVal, store it in minVal. After loop, set maxDiff to the difference between maxVal and minVal.
Algorithm 2: Set minVal to 1000 and maxVal to 0. Iterate through each number in the list. If the number is greater than maxVal, store it in maxVal. If the number is less than minVal, store it in minVal. After loop, set maxDiff to the difference between maxVal and minVal.
Which of these statements are true about these algorithms?
I. Algorithm 1 does not work on lists where the smallest value is at the start of the list or the largest value is at the end of the list.
II. Algorithm 2 does not work on lists that contain all negative numbers or all numbers over 1000.
Choose 1 answer:
Choose 1 answer:
I
II
I and II
Neither I or II
"Aba speak" is a game invented by school children to disguise what they're speaking.
When speaking, they transform each word following this algorithm:
For each letter in word:
If letter is vowel:
Add "b" after
Add that letter after "b"
Following that algorithm, how would they transform the word "avocado"?
Choose 1 answer:
Choose 1 answer:
abvobcabdob
avabocabadabo
abavobocabadobo
abavbvobocbcabadbdobo
abavobacabadoba
Determine what is printed by the following code.
values ⬅ [5, 6, 7, 0, 3, 3]
baz ⬅ 0
FOR EACH value IN values
{
if( value ≥ 7 )
{
baz ⬅ baz + 1
}
}
DISPLAY( baz )
1
0
7
6
Determine what is printed by the following code.
list ⬅ [11, 2, 8, 6, 4, 2, 5, 6, 9, 12]
fizz ⬅ 0
thud ⬅ 0
FOR EACH item IN list
{
if( item MOD 3 = 2 )
{
thud ⬅ thud + 1
}
fizz ⬅ fizz + 1
}
DISPLAY( thud / fizz )
0
1
0.5
5/10
A programmer for a weather website needs to display the proportion of days with freezing temperatures in a given month.
Their algorithm will operate on a list of temperatures for each day in the month. It must keep track of how many temperatures are below or equal to 32. Once it's done processing the list, it must display the ratio of freezing days over total days.
Which of these correctly expresses that algorithm in pseudocode?
numFreezing ← 0
numDays ← 0
FOR EACH temp IN temps {
IF (temp ≤ 32) {
numFreezing ← numFreezing + 1
}
numDays ← numDays + 1
DISPLAY(numFreezing/numDays)
}
numFreezing ← 0
numDays ← 0
FOR EACH temp IN temps {
IF (temp ≤ 32) {
numFreezing ← numFreezing + 1
}
numDays ← numDays + 1
}
DISPLAY(numFreezing/numDays)
numFreezing ← 0
numDays ← 0
FOR EACH temp IN temps {
IF (temp < 32) {
numFreezing ← numFreezing + 1
}
numDays ← numDays + 1
}
DISPLAY(numFreezing/numDays)
numFreezing ← 0
numDays ← 0
FOR EACH temp IN temps {
IF (temp ≤ 32) {
numFreezing ← numFreezing + 1
numDays ← numDays + 1
}
}
DISPLAY(numFreezing/numDays)
A programmer is deciding between using a linear or binary search to find a target value in a sorted list. Which of the following is true?
In all cases, a binary search of a sorted list requires fewer comparisons than a linear search.
Generally, the advantage of using a binary search over a linear search increases as the size of the list increases.
A linear search will generally run faster than a binary search because a linear search requires fewer lines of code to implement.
Using a linear search is preferable to using a binary search if there is a chance that the target may not be found in the list.
An algorithm has been developed to compute the sum of all the elements in a list of integers.
Which of the following programming structures must be added to the existing algorithm so that the new algorithm computes the sum of only the even integers in the list?
Iteration
Searching
Selection
Sequencing
An algorithm will be used to identify the maximum value in a list of one or more integers. Consider the two versions of the algorithm below.
Algorithm I : Set the value of a variable max to − 1. Iterate through the list of integer values. If a data value is greater than the value of the variable max, set max to the data value.
Algorithm II : Set the value of a variable max to the first data value. Iterate through the remaining values in the list of integers. If a data value is greater than the value of the variable max, set max to the data value.
Which of the following statements best describes the behavior of the two algorithms?
Both algorithms work correctly on all input values.
Algorithm I always works correctly, but Algorithm II only works correctly when the maximum value is not the first value in the list.
Algorithm II always works correctly, but Algorithm I only works correctly when the maximum value is greater than or equal to − 1.
Neither algorithm will correctly identify the maximum value when the input contains both positive and negative input values.
Central High School keeps a database of information about each student, including the numeric variables numberOfAbsences and gradePointAverage. The expression below is used to determine whether a student is eligible to receive an academic award.
(numberOfAbsences ≤ 5) AND (gradePointAverage > 3.5)
Which of the following pairs of values indicates that a student is eligible to receive an academic award?
numberOfAbsences = 3, gradePointAverage = 3.5
numberOfAbsences = 5, gradePointAverage = 3.8
numberOfAbsences = 6, gradePointAverage = 3.4
numberOfAbsences = 6, gradePointAverage = 3.6
Consider the following code segment, which uses the variables r, s, and t.
r ← 1
s ← 2
t ← 3
r ← s
s ← t
DISPLAY (r)
DISPLAY (s)
11
12
23
32
A certain computer game is played between a human player and a computer-controlled player. Every time the computer-controlled player has a turn, the game runs slowly because the computer evaluates all potential moves and selects the best one.
Which of the following best describes the possibility of improving the running speed of the game?
The game’s running speed can only be improved if the game is played between two human players instead of with the computer-controlled player.
The game’s running speed might be improved by using a process that finds approximate solutions every time the computer-controlled player has a turn.
The game’s running speed cannot be improved because computers can only be programmed to find the best possible solution.
The game’s running speed cannot be improved because the game is an example of an algorithm that does not run in a reasonable time
Determine what is printed by the following code.
numbers ⬅ [7, 4, 1, 6, 4, 11, 3]
baz ⬅ 0
FOR EACH value IN numbers
{
if( value < 3 )
{
baz ⬅ baz + 1
}
}
DISPLAY( baz )
0
1
none of the above
Determine what is printed by the following code.
numbers ⬅ [8, 5, 7, 1, 12, 12]
fred ⬅ 0
FOR EACH number IN numbers
{
if( number MOD 2 = 0 )
{
fred ⬅ fred + 1
}
}
DISPLAY( fred )
3
2
1
0
100 dancers are performing in a light show. An algorithm is being used to determine what color light each dancer should have. The color should be blue if and only if the dancer is not on the edge and is in an even row. Which of the following selection statements correctly assigns the blue color?
What will print?
1
2
11
1
2
21
1
2
3
11
1
2
3
21
What value is returned as a result of the call mystry(x)?
x * (x+1)
2x
2(x-1)
x3 +1
What is printed as a result of the call stri("COMPSCI")?
COMPSCI
COMPSC
COMPS
COMP
COM
CO
C
COMPSCI
OMPSCI
MPSCI
PSCI
SCI
CI
I
CO
COM
COMP
COMPS
COMPSC
COMPSCI
C
CO
COM
COMP
COMPS
COMPSC
COMPSCI
What color is 00FF00?
Green
Blue
Red
Yellow
When the function is called, the smaller of two numbers is displayed. What Boolean expression would not work in line 12 in order to accomplish this goal?
What will be the order of letters printed to the console when this program is run?
a b c
a b c b c b c
a b c b c
a b c a
What text will be ouput by the program?
Output A
Output B
Output C
Output D
What text will be ouput by the program?
Less than 10
Less than 20
Less than 30
30 or more
What number will be output by the console.log command on line 5?
10
25
30
35
A museum charges different prices based on the day of the week and age of the visitor. The pricing rules are shown below.
On Tuesday and Thursday children 10 and under get in free ($ 0).
For all other days and ages the cost is ten dollars ($ 10).
The visitor's age is stored in the variable age, the day of the week is stored in a variable day, and the price in dollars is stored in the variable price. Which piece of code will correctly decide the price for each ticket.
A movie theater charges different ticket prices based on a customer's age. The prices are shown in the table below.
Age | Ticket Price
12 and younger | $5
13 to 64 | $8
65 and older | $6
The customer's age is stored in the variable age and the price is stored in the variable price. Which piece of code will correctly decide the price for each ticket.
What will the value of the variable bags be at the end of the flowchart shown here?
1
2
3
4
