wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

AP CSP Midterm Review

Total questions: 22

Worksheet time: 36mins

Name
Class
Date
1.
What kind of data does a float variable contain?
a)
Whole Numbers
b)
words and letters
c)
Decimal numbers
d)
true or false
2.
What type of variable is "help"?
a)
Integer
b)
Float
c)
String
d)
List
3.
A photographer is manipulating a digital image and overwriting the original image. Which of the following describes a lossy transformation of the digital image?
a)
Creating the gray scale of an image by averaging the amounts of red, green, and blue in each pixel and assigning this new value to the corresponding pixel in the new image. The new value of each pixel represents a shade of gray, ranging from white to black.
b)
Creating a mirrored image by swapping the RGB values from pixels on the left side of an image with RGB values from pixels on the right side of an image.
c)
Swapping the Red and Green values of each pixel so that areas that were red now appear green and vice versa.
d)
Creating the negative of an image by creating a new RGB triplet for each pixel in which each value is calculated by subtracting the original value from 255. The negative of an image is reversed from the original; light areas appear dark, and colors are reversed.
4.
Which of the following statements are true about lossless compression?
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.
a)
I only
b)
II only
c)
I and II
d)
Neither I nor II
5.
A chat Website allows users to post messages to the site. When a user posts a message, the message itself is considered data. In addition to the data, the site stores the following metadata. The time the message was posted and the city from which the message was posted.
Which of the following questions can NOT be answered using only the data and metadata collected?
a)
What topics are most frequently posted about in a particular city?
b)
When is a particular city most active on the site?
c)
Which users post messages most frequently?
d)
What topics are most frequently posted about during a particular time period?
6.
ASCII is a character-encoding scheme that uses 7 bits to represent each character. The decimal (base 10) values 65 through 90 represent the capital letters A through Z, as shown in the table below. What ASCII character is represented by the binary (base 2) number 1010001?
a)
S
b)
R
c)
Q
d)
P
7.
Consider the following numbers Binary 1001001Decimal 70Hexadecimal 4E Which of the following lists the numbers in order from least to greatest?
a)
Binary 1001001, Decimal 70, Hexadecimal 4E
b)
Decimal 70, Binary 1001001, Hexadecimal 4E
c)
Binary 1001001, Hexadecimal 4E, Decimal 70
d)
Decimal 70, Hexadecimal 4E, Binary 1001001
8.
A red triangle is pictured below in a grid of squares. It is currently facing upward, and can only move using the MoveTriangle procedure, shown below. The triangle can move onto white and gray squares, but not onto the black squares.
PROCEDURE MoveTriangle (numMoves, numTurns)
{ 
REPEAT
numMoves TIMES   

MOVE_FORWARD() 
}
 
REPEAT numTurns TIMES 
{   
TURN_RIGHT() 
}
}
Which of the following instructions will get the red triangle to the gray square?
a)
 
MoveTriangle (1, 1) MoveTriangle (1, 1) MoveTriangle (3, 1) MoveTriangle (3, 0)
b)
MoveTriangle (4, 1)
MoveTriangle (4, 0)
c)
MoveTriangle (1, 1)
MoveTriangle (1, 3)
MoveTriangle (3, 1)
MoveTriangle (3, 0)
 
d)
MoveTriangle (1, 1)
MoveTriangle (1, 3)
MoveTriangle (3, 3)
MoveTriangle (3, 0)
9.
Efficiency of algorithms is most often analyzed based on which of the following characteristics?
a)
The number of lines of computer code needed to implement the algorithm.
b)
The time and memory space necessary to run the algorithm.
c)
How easy or difficult the algorithm is to understand.
d)
The size of the output obtained after running the algorithm.
10.
A student purchases a single-user license of an online textbook and wants to share the textbook with their classmates. Under what conditions is it acceptable for the student to share this textbook?
a)
If the student shares only three chapters of the textbook with their classmates
b)
If the textbook is only shared with people in the student’s class
c)
If the textbook is only shared with one other classmate
d)
If the student gets permission from the textbook’s copyright owner
11.
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.
a)
1 and 3
b)
1, 2 and 3
c)
1 and 3
d)
2 and 3
12.
Which of the following statements about abstraction is true?
a)
Abstraction requires users to understand the low-level details of a system.
b)
Abstraction reduces information and detail to facilitate focus on relevant concepts.
c)
Abstraction increases the run-time complexity of a program.
d)
Abstraction compresses a program file to reduce file size.
13.
A programmer is writing code to switch the values of two integer variables, namely 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.
a)
Yes, the code correctly switches the values of 'a' and 'b'.
b)
No, but it will work correctly if statements 1. and 3. are switched.
c)
No, but it will work correctly if statements 2. and 3. are switched.
d)
No, but it will work correctly if statements 1. and 2. are switched.
14.
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 n?
a)
4
b)
8
c)
16
d)
32
15.
If the number of steps that an algorithm takes is equal to a linear function of the input size, then which of the following statements is true regarding the runtime of the algorithm?
a)
The run-time is directly proportional to the input size.
b)
The run-time is inversely proportional to the input size.
c)
The run-time of the program does not change with respect to the input size.
d)
The run-time first increases and then decreases as the input size is increased.
16.
Which of the following statements is true about the output of this circuit?
a)
The output of the circuit is always true
b)
The output of the circuit is the same as the value of input A
c)
The output of the circuit is the same as the value of input B
d)
The output of the circuit is always false
17.
The Traveling Salesman Problem is a problem in theoretical computer science in which one tries to find the shortest route that passes through every point in a set, once and only once. The optimal solution to the problem for an arbitrary set of of points cannot be found in a reasonable amount of time, that is, it cannot be found in polynomial time. However, we can find an approximation to the optimal solution in a reasonable amount of time. It would be best to find the approximate solution using a
a)
The output of the circuit is always Heuristic algorithm
b)
Brute-Force algorithm
c)
Recursive algorithm
d)
Dynamic algorithm
18.
In a freezer, the temperature can be increased, but should not go above 0° C. It can, however, be exactly equal to 0° C. The unfinished code for increasing the temperature in a freezer is shown below. The variable temp represents the current temperature in degrees Celsius.
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
}
a)
I. and II. only
b)
I. and III. only
c)
I. and IV. only
d)
III. and IV. only
19.
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?
a)
The long data type can store 2^48 times as many distinct values as the short data type
b)
The long data type can store 2^64 times as many distinct values as the short data type
c)
The long data type can store 2^16 times as many distinct values as the short data type
d)
The short data type can store 4 times as many distinct values as the long data type
20.
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.
a)
I, II
b)
I, III
c)
I, II, III
d)
None of the options
21.
Sam wants to send an image that uses lossy compression image format, what file type should he use?
a)
gif
b)
png
c)
jpeg
d)
pik
22.
What is the slowest type of sort
a)
Merge
b)
Selection
c)
Bubble
d)
Quick