CB Quiz Corrections and Review
Score= 50/52 = 96%
What I Got Wrong
32.Which of the following is a true statement about the use of public key encryption in transmitting messages?
- My answer: Public key encryption is not considered a secure method of communication because a public key can be intercepted.
- Right answer: Public key encryption enables parties to initiate secure communications through an open medium, such as the Internet, in which there might be eavesdroppers
- Why I got it wrong: I didn’t/don’t know much about public key so I went with the answer that seemed most right to me
- Why the answer is right: A public key is used to encrypt messages, while a private key is used to decrypt messages. Public key encryption is still considered secure even if a public key is obtained by an unauthorized individual.
34.In a science experiment, result X is expected to occur 25% of the time and result Y is expected to occur the remaining 75% of the time. The following code segment is intended to simulate the experiment if there are 100 trials.
Line 1: xCount 0
Line 2: yCount 0
Line 3: REPEAT 100 TIMES
Line 4: {
Line 5: IF(RANDOM(1, 4) = 1)
Line 6: {
Line 7: xCount xCount + 1
Line 8: }
Line 9: IF(RANDOM(1, 4) > 1)
Line 10: {
Line 11: yCount yCount + 1
Line 12: }
Line 13: }
Line 14: DISPLAY(“Result X occurred”)
Line 15: DISPLAY(xCount)
Line 16: DISPLAY(“times and result Y occurred”)
Line 17: DISPLAY(yCount)
Line 18: DISPLAY(“times.”)
A programmer runs the code segment, and the following message is displayed.
Result X occurred 24 times and result Y occurred 70 times.
The result shows that 94 trials were counted, rather than the intended 100 trials. Which of the following changes to the code segment will ensure a correct simulation of the experiment?
- My answer: Interchanging lines 7 and 11 will not correct this error.
- Right answer: Replacing line 9 with ELSE
- Why I got it wrong: I had spent too long on it and was getting a little braindead and realized it was time to move on so I clicked on a random answer.
- Why the answer is right: An incorrect trial count occurs because there are two calls to RANDOM for each iteration of the loop instead of one. By replacing line 9 with an ELSE statement, the code segment will increment xCount approximately 25% of the time and will increment yCount otherwise.
Questions I Didn’t Have Time For
53.A list of numbers has n elements, indexed from 1 to n. The following algorithm is intended to display true if the value target appears in the list more than once and to display false otherwise. The algorithm uses the variables position and count. Steps 4 and 5 are missing.
Step 1: Set count to 0 and position to 1. Step 2: If the value of the element at index position is equal to target, increase the value of count by 1. Step 3: Increase the value of position by 1. Step 4: (missing step) Step 5: (missing step) Which of the following could be used to replace steps 4 and 5 so that the algorithm works as intended?
- Answer: Step 4: Repeat steps 2 and 3 until the value of position is greater than n. Step 5: If count is greater than or equal to 2, display true. Otherwise, display false.
- Answer Explanation: Step 4 checks every element of the list, incrementing count each time target appears. Step 5 prints true if and only if count appears multiple times in the list.
- Concept: Represent algorithmic processes without using a programming language.
54.Delivery trucks enter and leave a depot through a controlled gate. At the depot, each truck is loaded with packages, which will then be delivered to one or more customers. As each truck enters and leaves the depot, the following information is recorded and uploaded to a database.
- The truck’s identification number
- The truck’s weight
- The date and time the truck passes through the gate
- Whether the truck is entering or leaving the depot
-
Using only the information in the database, which of the following questions CANNOT be answered?
- Answer: What is the average number of customer deliveries made by each truck on a particular day?
- Answer Explanation: The data captured each time a truck enters or leaves the depot do not include any information about the number of customers or deliveries associated with the truck.
- Concept: : Explain how knowledge can be generated from data.
55.A code segment is intended to transform the list utensils so that the last element of the list is moved to the beginning of the list.
For example, if utensils initially contains [“fork”, “spoon”, “tongs”, “spatula”, “whisk”], it should contain [“whisk”, “fork”, “spoon”, “tongs”, “spatula”] after executing the code segment.
Which of the following code segments transforms the list as intended?
- Answer: len LENGTH(utensils) temp utensils[len] REMOVE(utensils, len) INSERT(utensils, 1, temp)
- Answer Explanation: This code segment assigns the value of the last element of the list to the variable temp, then removes the last element of the list, then inserts temp as the first element of the list.
- Concept: Implement and apply an algorithm.
56.Each student at a school has a unique student ID number. A teacher has the following spreadsheets available.
- Spreadsheet I contains information on all students at the school. For each entry in this spreadsheet, the student name, the student ID, and the student’s grade point average are included.
- Spreadsheet II contains information on only students who play at least one sport. For each entry in this spreadsheet, the student ID and the names of the sports the student plays are included.
- Spreadsheet III contains information on only students whose grade point average is greater than 3.5. For each entry in this spreadsheet, the student name and the student ID are included.
-
Spreadsheet IV contains information on only students who play more than one sport. For each entry in this spreadsheet, the student name and the student ID are included. The teacher wants to determine whether students who play a sport are more or less likely to have higher grade point averages than students who do not play any sports. Which of the following pairs of spreadsheets can be combined and analyzed to determine the desired information?
- Answer: Spreadsheets I and II
- Answer Explanation: The desired information can be determined by using the student IDs in spreadsheet II to identify the students who play a sport. Once the students who play a sport are identified, the grade point averages of students who play sports in spreadsheet I can be compared to the grade point averages of all other students in spreadsheet I.
- Concept: : Explain how knowledge can be generated from data.
57.A certain computer has two identical processors that are able to run in parallel. The following table indicates the amount of time it takes to execute each of four processes on a single processor. Assume that none of the processes is dependent on any of the other processes.
P- 30 seconds, Q-10 Seconds, R-20 Seconds, S-15 Seconds
- Answer: Running processes P and Q on one processor and processes R and S on the other processor
- Answer Explanation: With two processors running in parallel, execution time is minimized when the processors take on as close to an equal workload as possible. Running processes P and Q on one processor will take a total of 40 seconds. Running processes R and S on the other processor will take a total of 35 seconds. As the processors run in parallel, all four operations are completed in 40 seconds.
- Concept: Evaluate solution options.
58.RunRoutr is a fitness tracking application for smartphones that creates suggested running routes so that users can run with each other. Upon downloading the application, each user creates a username, a personal profile, and a contact list of friends who also use the application. The application uses the smartphone’s GPS unit to track a user’s location, running speed, and distance traveled. Users can use the application to review information and statistics about their previous runs.
At the beginning of a run, users indicate the distance they want to run from their current location, and the application suggests a running route. Once a user accepts a suggested route, the application shares the suggested route with other compatible users in the area so that they can run together. Users are considered compatible if they are on each other’s contact lists or if they typically run at similar speeds.
A basic RunRoutr account is free, but it displays advertisements that are targeted to individual users based on data collected by the application. For example, if a user’s running route begins or ends near a particular store, the application may display an advertisement for that store. Users have the ability to pay a monthly fee for a premium account, which removes advertisements from the application.
- Answer: The user’s geographic position
- Answer Explanation: In order to suggest a running route, the application needs to know the current location of the user. This information is collected from the user’s device.
- Concept: Generalize data sources through variables.
59.Same as previous
- Answer: The current locations of other RunRoutr users
- Answer Explanation: In order to share Adrianna’s running route with nearby users, the application needs to know the current locations of users other than Adrianna. This information is collected from other user’s devices, not Adrianna’s device.
- Concept: Generalize data sources through variables.
60.Same as previous- what is a benefit?
- Answer: Users of the application may see health benefits as a result of the application encouraging them to exercise with each other.
- Answer Explanation: The application can be used to connect users with other nearby users, which may encourage users to exercise together. This may have the effect of improving user health.
- Concept: Describe the impact of a computing innovation.
61.Same as previous- Privacy Risk?
- Answer: Users of the application may have the ability to determine information about the locations of users that are not on their contact lists.
- Answer Explanation: The application will inform a user whenever a nearby compatible user starts a run. This could allow users to determine the location of a stranger, which is considered a privacy concern
- Concept: Describe the impact of gathering data.
62.Same as previous- Group least likely to recieve targeted ads?
- Answer: Individuals who sign up for a premium account
- Answer Explanation: TUsers with a premium account do not receive advertisements cause only free get ads.
- Concept: Describe the impact of gathering data.
63.The following table shows the value of expression based on the values of input1 and input2.
Value of input1 Value of input2 Value of expression true true false true false true false true true false false true Which of the following expressions are equivalent to the value of expression as shown in the table?
- Answer: (NOT input1) OR (NOT input2), NOT (input1 AND input2)
- Answer Explanation: When input1 and input2 are both true, the expression (input1 AND input2) is true, so NOT (input1 AND input2) will evaluate to false. In all other cases, (input1 AND input2) will evaluate to false, so NOT (input1 AND input2) will evaluate to true.
- Concept: Implement and apply an algorithm.
64.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?
- Answer: Line 8, Line 10
- Answer Explanation: Line 8: This line should be removed. This return statement causes execution of the procedure to end early. As a result, if age is less than 18, result will never be assigned the value “minor”. Line 10: . This line should be removed. This statement causes result to be assigned the value “adult”, even if it should have been assigned the value “senior citizen”.
- Concept: Identify and correct errors in algorithms and programs, including error discovery through testing.
65.Assume that the Boolean variable hot is assigned the value true and the Boolean variable humid is assigned the value false. Which of the following will display the value true ?
- Answer: If not hot display hot or humid, if hot or humid display hot
- Answer Explanation: Since NOT humid evaluates to true, the body of the IF statement is executed. Since hot OR humid evaluates to true, true is displayed., Since hot OR humid evaluates to true, the body of the IF statement is executed. Since hot is true, true is displayed.
- Concept: : Determine the result of code segments.
66.In a certain video game, players are awarded bonus points at the end of a level based on the value of the integer variable timer. The bonus points are awarded as follows.
If timer is less than 30, then 500 bonus points are awarded. If timer is between 30 and 60 inclusive, then 1000 bonus points are awarded. If timer is greater than 60, then 1500 bonus points are awarded. Which of the following code segments assigns the correct number of bonus points to bonus for all possible values of timer ?
- Answer/explanation: This code segment assigns 500 bonus points by default. If timer is less than 30, no additional bonus points are added. If timer is between 30 and 60 inclusive, bonus is incremented by 500 in the first IF block. If timer is greater than 60, bonus is incremented by 500 twice (once in each IF block). The correct number of bonus points is assigned to bonus for all possible values of timer. In this code segment, if timer is greater than 60, bonus is assigned 1500 in the first IF block. If timer is between 30 and 60, inclusive, bonus is assigned 1000 in the second IF block. If timer is less than 30, bonus is assigned 500 in the third IF block. The correct number of bonus points is assigned to bonus for all possible values of timer.
- Concept: Implement and apply an algorithm.
67.The following spinner is used in a game. The region labeled “blue” represents 1/4 of the spinner. The regions labeled “orange” and “purple” are equal in size. Which of the following code segments can be used to simulate the behavior of the spinner?
- Answer/explanation: For this spinner, there is a 1/4 chance of “blue”. The remaining 3/4 of the time, “orange” and “purple” are equally likely. If the first call to RANDOM returns 1 (which occurs 1/4 of the time), the code segment prints “blue”. Otherwise, if the second call to random returns 1 (which occurs 1/2 of the time that “blue” does not occur), the code segment prints “orange”. The other 1/2 of the time that “blue” does not occur, the code segment prints “purple”.
- Concept: Implement and apply an algorithm.
68.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?
- Answer: [10, 10, 20, 20, 10, 10] [30, 50, 40, 10, 20, 40]
- Answer Explanation: The code segment will iterate over myList from right to left, removing each element that is equal in value to the element immediately preceding it. For this list, the code segment will remove the sixth element (10), the fourth element (20), and the second element (10). This results in the list [10, 20, 10], which still contains duplicates. The code segment will iterate over myList from right to left, removing each element that is equal in value to the element immediately preceding it. This list does not contain any pairs of adjacent elements that are equal in value, so no elements will be removed even though the value 40 appears twice in the list.
- Concept: Determine and design an appropriate method or approach to achieve the purpose.
69.A group of students take hundreds of digital photos for a science project about weather patterns. Each photo file contains data representing the level of red, green, and blue for each pixel in the photo. The file also contains metadata that describes the date, time, and geographic location where the photo was taken. For which of the following goals would analyzing the metadata be more appropriate than analyzing the data?
- Answer: Determining the chronological order of the photos, Determining whether two photos were taken at the same location on different days
- Answer explanation: The time and date that a photo is taken is considered metadata about the image. This information can be used to determine the chronological order of the images. The location and date that a photo is taken is considered metadata about the image. This information can be used to determine whether two pictures were taken at the same location on different dates.
- Concept: Explain how knowledge can be generated from data.
70.The following procedures are available for string manipulation.
Procedure Call Explanation substring(str, start, end) Returns a substring of consecutive characters of str starting with the character at position start and ending with the character at position end. The first character of str is considered position 1. For example, substring(“delivery”, 3, 6) returns “live”. concat(str1, str2) Returns a single string consisting of str1 followed by str2. For example, concat(“key”, “board”) returns “keyboard”. len(str) Returns the number of characters in str. For example, len(“key”) returns 3. A programmer wants to create a new string by removing the character in position n of the string oldStr. For example, if oldStr is “best” and n is 3, then the new string should be “bet”. Assume that 1 < n < len(oldStr).
Which of the following code segments can be used to create the desired new string and store it in newStr ?
-
Answer: left substring(oldStr, 1, n - 1) right substring(oldStr, n + 1, len(oldStr)) newStr concat(left, right) ,,, newStr substring(oldStr, 1, n - 1) newStr concat(newStr, substring(oldStr, n + 1, len(oldStr)))
- Answer Explanation: This code segment assigns the characters to the left of position n to the variable left and the characters to the right of position n to the variable right. It then concatenates left and right and assigns the result to newStr. For example, if oldStr is “best” and n is 3, the code segment assigns “be” to left, “t” to right, and “bet” to newStr. This code segment assigns the characters to the left of position n to newStr. The code segment then concatenates newStr with the substring consisting of the characters to the right of position n. For example, if oldStr is “best” and n is 3, the code segment assigns “be” to newStr, then concatenates “be” and the substring “t” and assigns the result “bet” to newStr.
- Concept: Use abstraction to manage complexity in a program.