Select the best answer for each question. When you're finished, click Submit Exam to see your score and explanations.
Question 1.Consider the code segment below. You can assume that Mystery returns either true or false, and Input_List_From_User asks the user for several values and returns them as a list.
Mystery
true
false
Input_List_From_User
inputList ← Input_List_From_User () resultList ← [] FOR EACH item IN inputList { IF (Mystery (item)) { APPEND (resultList, item) } }
Which of the following best describes the value of resultList?
resultList
inputList
Question 2.The computer science department at a university is using the following program to determine the average GPA of the department on a 4 point scale. Some GPAs were entered incorrectly with values greater than 4 and should be excluded from the average. The students’ GPAs are stored in the list studentGPAs, which is indexed from 1 to n.
studentGPAs
gradePointAverageSum ← 0 numGPAs ← LENGTH (studentGPAs) i ← 1 REPEAT n TIMES { <MISSING CODE> } DISPLAY (gradePointAverageSum / numGPAs)
Which of the following code segments can replace <MISSING CODE> so that the program works as intended?
<MISSING CODE>
IF (studentGPAs[i] ≥ 4) { gradePointAverageSum ← gradePointAverageSum + studentGPAs[i] } ELSE { numGPAs ← numGPAs - 1 } i ← i + 1
IF (studentGPAs[i] ≤ 4) { gradePointAverageSum ← gradePointAverageSum + studentGPAs[i] } ELSE { numGPAs ← numGPAs - 1 } i ← i + 1
IF (studentGPAs[i] ≤ 4) { gradePointAverageSum ← gradePointAverageSum + studentGPAs[i] i ← i + 1 } ELSE { numGPAs ← numGPAs - 1 }
IF (studentGPAs[i] > 4) { gradePointAverageSum ← gradePointAverageSum + studentGPAs[i] numGPAs ← numGPAs - 1 } i ← i + 1
Question 3.Why is it important to focus on programming style in addition to programming functionality?
Question 4.ASCII uses 7 bits to represent characters. The decimal values 65 through 90 represent capital letters A through Z. What ASCII character is represented by the binary number 1010001?
1010001
Question 5.A programmer wrote the following program intending to print the maximum value in list. You can assume list contains numerical values and has at least one element.
list
max ← 0 FOR EACH num IN list { IF (num > max) { max ← num } } DISPLAY (max)
What change is needed to correctly display the maximum value for any list of integers?
max ← 0
max ← -∞
max ← list[1]
IF (num ≥ max)
Question 6.What is the purpose of the Digital Millennium Copyright Act (DMCA)?
Question 7.A blogging website allows users to post messages and comment on other messages. When a user posts a message, in addition to the message text the site stores:
Question 8.Consider the procedure below.
PROCEDURE Mystery (number) { RETURN ((number MOD 2) = 0) }
Which of the following best describes the behavior of Mystery?
number
Question 9.Which of the following activities poses the LEAST potential cybersecurity risk?
Question 10.Consider the code segment below. You can assume that Input_List_From_User asks the user for several values and returns them as a list.
inputList ← Input_List_From_User () resultList ← [] FOR EACH item IN inputList { APPEND (resultList, Mystery (item)) }
How would you best describe the value of resultList?
Question 11.Which of the following activities poses the greatest personal cybersecurity risk?
Question 12.Assume we simulate flipping a coin n times. We track heads_counter (the number of heads) and flip_counter (the total flips). We want to display whether we had an odd or even number of tails.
n
heads_counter
flip_counter
Two algorithms are proposed:
Algorithm A: Set num_tails to flip_counter - heads_counter. If num_tails MOD 2 = 0 display "EVEN", otherwise display "ODD".
num_tails
flip_counter - heads_counter
num_tails MOD 2 = 0
Algorithm B: Set even_flips to (n MOD 2) = 0 and even_heads to (heads_counter MOD 2) = 0. If even_flips equals even_heads display "EVEN", otherwise display "ODD".
even_flips
(n MOD 2) = 0
even_heads
(heads_counter MOD 2) = 0
Which statement is true?
Question 13.Which statement describes a limitation of using a heuristic approach to solve a problem?
Question 14.We want to create an algorithm swapValues. Given two variables x and y, the result should have their values swapped. Which of the following algorithms correctly swaps the values?
swapValues
x
y
y ← x temp ← x x ← y
x ← y y ← x
temp ← x x ← y y ← temp
temp ← x y ← temp y ← x
Question 15.Computers are often used to search large data sets to find useful patterns. Which task is an example where finding patterns is needed to produce useful information?
Question 16.A bank uses a program to determine whether to ring an alarm. It uses these Boolean variables:
vaultClosed
heardNoise
sawMovement
NOT vaultClosed OR (heardNoise AND sawMovement)
heardNoise AND vaultClosed
NOT vaultClosed AND sawMovement
heardNoise AND sawMovement
Question 17.Consider the procedure below.
PROCEDURE Mystery (word, list) { FOR EACH item IN list { IF (item = word) { RETURN (true) } } RETURN (false) }
word
Question 18.Biologists attach GPS tracking collars to several birds. For each bird they record:
Question 19.A program is written in a high-level programming language. Which of the following is true about that program?
Question 20.A large data set contains information about all students in colleges across the United States. For each student it stores:
Question 21.A city government is trying to reduce the digital divide between groups with differing access to computing and the Internet. Which action is MOST likely to be effective?
Question 22.Which of the following programs is most likely to benefit from the use of a heuristic?
Question 23.A website is considering storing the geolocation of users who access the site. Which of the following is LEAST likely to occur as a result of this update?
Question 24.Consider the following program. The initial value of a is 0 and the initial value of b is 1.
a
b
IF (b = 0) { IF (b = 1) { DISPLAY ("Karel") } } ELSE { IF (a = 1) { DISPLAY ("Tracy") } ELSE { DISPLAY ("Dog") } DISPLAY ("Turtle") }
What is displayed as a result of running this program?
Question 25.Given the procedure below, how can you best describe the result it returns?
PROCEDURE Mystery (list, target) { length ← LENGTH (list) i ← 1 REPEAT length TIMES { IF (list[i] = target) { REMOVE(list, i) } ELSE { i ← i + 1 } } RETURN (list) }
target
Question 26.Given the following tasks, which one clearly uses selection (i.e., a conditional like IF)?
IF
Question 27.What is the minimum number of bits needed to represent a number on a 0 to 10 scale (inclusive)?
Question 28.Consider the following code segment:
i ← 1 counter ← 1 REPEAT UNTIL <MISSING CONDITION> { DISPLAY (i) i ← i * 2 counter ← counter + 1 }
Which replacement for <MISSING CONDITION> will display the first 10 powers of 2?
<MISSING CONDITION>
i ≥ 100
counter > 10
counter ≥ 10
counter = i * 2
Question 29.A search engine has a trend-tracking feature that provides information on how popular a search term is. The data can be filtered by region, date, and search term. Which of the following questions is LEAST likely to be answerable using this feature?
Question 30.Which of the following describes a limitation of cloud computing?
Submit Exam