A student writes a program that processes thousands of currency transactions and rounds the results to the nearest cent. Over time, they notice the program's totals are off by several dollars.
Question 2
2.
A student sends a private file to a teacher via email. Which approach provides the strongest protection against unauthorized access during transfer?
Question 3
3.
A school’s meal tracking system records data each time a student buys a lunch in the cafeteria. For every transaction, the system stores:
The student's name and ID number
The date and time of purchase
The items purchased and their prices
The payment method (e.g., prepaid card, cash)
Which of the following CANNOT be determined from the information stored in the system?
Responses:
Question 4
4.
count ← 0
REPEAT UNTIL (count > 5)
{
IF (count MOD 2 = 0)
{
DISPLAY(count)
}
count ← count + 1
}
Question 5
5.
result ← 0
REPEAT 4 TIMES
{
result ← result + 2
IF (result MOD 3 = 0)
{
result ← result + 1
}
}
Question 6
6.
x ← 5
y ← 3
REPEAT UNTIL (x ≤ 0)
{
y ← y + 1
x ← x - 1
IF (y MOD 2 = 0)
{
x ← x - 1
}
}
What is the value of y after the code segment executes?
Question 7
7.
x ← 0
y ← 0
REPEAT 5 TIMES
{
y ← y + 1
IF (y MOD 2 = 1)
{
x ← x + y
}
ELSE
{
x ← x + 2
}
}
What is the value of x after the code segment executes?
Question 8
8.
counter ← 0
sum ← 0
REPEAT UNTIL (counter > 5)
{
IF (counter ≠ 3)
{
sum ← sum + counter
}
counter ← counter + 1
}
What is the value of sum after the code segment executes?
Question 9
9.
aList ← [2, 4, 6, 8, 10]
count ← 0
result ← 0
FOR EACH item IN aList
{
IF (item MOD 4 = 0)
{
count ← count + 1
result ← result + item
}
}
What are the values of count and result after this code segment executes?
Question 10
10.
x ← 1
REPEAT UNTIL (x > 30)
{
IF (x MOD 3 = 0 AND x MOD 5 = 0)
{
DISPLAY("both")
}
ELSE
{
IF (x MOD 3 = 0)
{
DISPLAY("three")
}
ELSE
{
IF (x MOD 5 = 0)
{
DISPLAY("five")
}
}
}
x ← x + 1
}
How many times will "both" be displayed when this code segment executes?
Question 11
11.
a ← 0
b ← 0
REPEAT 4 TIMES
{
a ← a + 1
REPEAT a TIMES
{
b ← b + 1
}
}
}
What is the value of b after the code segment executes?
Question 12
12.
total ← 0
index ← 1
REPEAT UNTIL (index > 5)
{
IF (index MOD 2 = 0)
{
total ← total - index
}
ELSE
{
total ← total + index * 2
}
index ← index + 1
}
Question 13
13.
PROCEDURE mystery(n)
{
result ← 0
counter ← 0
REPEAT UNTIL (counter > n)
{
IF (counter MOD 3 = 0 OR counter MOD 5 = 0)
{
result ← result + counter
}
counter ← counter + 1
}
RETURN(result)
}
What is returned by the call mystery(10)?
Question 14
14.
PROCEDURE sumEvens(numList)
{
sum ← 0
FOR EACH num IN numList
{
IF (num MOD 2 = 0)
{
sum ← sum + num
}
}
RETURN(sum)
}
What will be returned by the call sumEvens([3, 8, 2, 9, 4])?
Question 15
15.
PROCEDURE mystery(aList, val)
{
count ← 0
FOR EACH item IN aList
{
IF (item > val)
{
count ← count + 1
}
}
RETURN(count)
}
What will be returned by the call mystery([15, 7, 22, 9, 18], 12)?
Question 16
16.
PROCEDURE transform(list1)
{
list2 ← []
FOR EACH item IN list1
{
IF (item < 0)
{
APPEND(list2, item * -1)
}
ELSE
{
APPEND(list2, item * 2)
}
}
RETURN(list2)
}
What will be returned by the call transform([-3, 4, 0, -2, 5])?
Question 17
17.
PROCEDURE modifyList(aList)
{
length ← LENGTH(aList)
i ← 1
REPEAT UNTIL (i > length)
{
IF (aList[i] MOD 3 = 0)
{
REMOVE(aList, i)
length ← length - 1
}
ELSE
{
i ← i + 1
}
}
RETURN(aList)
}
What will be returned by the call modifyList([6, 4, 9, 5, 12, 7])?
Question 18
18.
PROCEDURE process(aList)
{
result ← []
i ← 1
j ← LENGTH(aList)
REPEAT UNTIL (i > j)
{
APPEND(result, aList[i] + aList[j])
i ← i + 1
j ← j - 1
}
RETURN(result)
}
What will be returned by the call process([3, 1, 4, 2, 7])?
Question 19
19.
PROCEDURE f1(n)
{
IF (n ≤ 1)
{
RETURN(1)
}
ELSE
{
RETURN(n * f2(n - 1))
}
}
PROCEDURE f2(n)
{
IF (n ≤ 1)
{
RETURN(1)
}
ELSE
{
RETURN(n + f1(n - 1))
}
}
What will be returned by the call f1(3)?
Question 20
20.
PROCEDURE findPattern(wordList)
{
matchList ← []
FOR EACH word IN wordList
{
IF (LENGTH(word) > 3 AND word[1] = "a")
{
APPEND(matchList, word)
}
}
RETURN(matchList)
}
What will be returned by the call findPattern(["apple", "art", "about", "cat", "atom"])?
Question 21
21.
PROCEDURE insertItem(aList, item, position)
{
length ← LENGTH(aList)
IF (position < 1 OR position > length + 1)
{
RETURN(aList)
}
newList ← []
i ← 1
REPEAT UNTIL (i > length + 1)
{
IF (i = position)
{
APPEND(newList, item)
}
IF (i ≤ length)
{
APPEND(newList, aList[i])
}
i ← i + 1
}
RETURN(newList)
}
What will be returned by the call insertItem([10, 20, 30], 25, 2)?
Question 22
22.
PROCEDURE combine(list1, list2)
{
result ← []
len1 ← LENGTH(list1)
len2 ← LENGTH(list2)
minLen ← minimum(len1, len2)
i ← 1
REPEAT UNTIL (i > minLen)
{
APPEND(result, list1[i])
APPEND(result, list2[i])
i ← i + 1
}
RETURN(result)
}
PROCEDURE minimum(a, b)
{
IF (a ≤ b)
{
RETURN(a)
}
ELSE
{
RETURN(b)
}
}
What will be returned by the call combine([2, 4, 6], [3, 5])?
Question 23
23.
PROCEDURE calculateSum(listA, listB)
{
IF (LENGTH(listA) ≠ LENGTH(listB))
{
RETURN(0)
}
sum ← 0
i ← 1
len ← LENGTH(listA)
REPEAT UNTIL (i > len)
{
IF (listA[i] = listB[i])
{
sum ← sum + listA[i]
}
i ← i + 1
}
RETURN(sum)
}
What will be returned by the call calculateSum([5, 3, 7, 2], [8, 3, 7, 5])?
1
Question 25
25.
Convert 2391 in base 10 to binary
Question 24
24.
A file storage application allows users to save their files on cloud servers. A group of researchers gathered user data for the first eight years of the application’s existence. Some of the data are summarized in the following graphs. The line graph on the left shows the number of registered users each year. The line graph on the right shows the total amount of data stored by all users each year. The circle graph shows the distribution of file sizes currently stored by all users.
(note: 1 MB = 1,000 KB)
Which of the following best describes the average amount of data stored per user for the first eight years of the application’s existence?