Questions I got wrong
Q2
- Question:Which of the following has the greatest potential for compromising a user’s personal privacy?
- My Answer:The Internet Protocol (IP) address of the user’s computer
- Correct Answer:A group of cookies stored by the user’s Web browser
- Reflection: This option is incorrect. The IP address of a user’s computer is required for the user to send and receive information on the Internet. The IP address in itself does not contain any extra information about the user.
Q19
- Question:Which of the following best describes the contents of resultList after the code segment is executed?
- My Answer:All elements in inputList1 followed by all elements in inputList2
- Correct Answer:Only elements that appear in both inputList1 and inputList2
- Reflection: This option is incorrect. The resultList contains only items from inputList1 that are also found in inputList2.
Q21
- Question:In order to test the program, the programmer initializes numList to [0, 1, 4, 5]. The program displays 10, and the programmer concludes that the program works as intended.
- My Answer:The conclusion is incorrect; the program does not display the correct value for the test case [0, 1, 4, 5].
- Correct Answer:The conclusion is incorrect; using the test case [0, 1, 4, 5] is not sufficient to conclude the program is correct.
- Reflection: This option is incorrect. The program does display the correct sum of 10 for the test case [0, 1, 4, 5].
Q22
- Question:For which of the grids does the program correctly move the robot to the gray square?
- My Answer:Neither grid I nor grid II
- Correct Answer:Grid I only
- Reflection: This option is incorrect. Although the program will not move the robot to the gray square in Grid II, it will correctly move the robot to the gray square in Grid I.
Q28
- Question: Which of the following code segments can be used to assign the intended string to newString ?
- My Answer:newString ← substring(oldString, 3, len(oldString) - 2)
- Correct Answer:tempString ← substring(oldString, 3, len(oldString) - 2) newString ← substring(tempString, 1, len(tempString) - 2)
- Reflection: Incorrect. This code segment will remove only the first 2 characters of oldString.
Q29
- Question: What is displayed as a result of executing the code segment?
- My Answer: true false true
- Correct Answer: false false false
- Reflection: Incorrect. The fourth statement assigns the value false to a. The fifth statement assigns the value false to c.
Q31
- Question: Which of the following algorithms can be used to open the gate under the appropriate conditions?
- My Answer: Check if the time is outside of business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is closed. If it is, turn on the motor.
- Correct Answer: Check if the time is during business hours. If it is, check if the gate sensor is activated. If it is, check if the gate is open. If it is not, turn on the motor.
- Reflection: Incorrect. This algorithm will turn on the motor in some cases when the time is outside business hours.
Q32
- Question: A certain game keeps track of the maximum and minimum scores obtained so far. If num represents the most recent score obtained, which of the following algorithms correctly updates the values of the maximum and the minimum?
- My Answer: If num is greater than the minimum, set the minimum equal to num. Otherwise, if num is greater than the maximum, set the maximum equal to num.
- Correct Answer: If num is less than the minimum, set the minimum equal to num. Otherwise, if num is greater than the maximum, set the maximum equal to num.
- Reflection: Incorrect. The first check is incorrect. The minimum needs to be updated if the new number is less than the minimum, not greater.
Q33
- Question: Which of the following can be used as a replacement for MISSING STATEMENT so that the code segment works as intended?
- My Answer: REPEAT 1 TIMES
- Correct Answer: REPEAT 2 TIMES
- Reflection: Incorrect. This code segment leaves the robot one row above its starting position and one row below the gray square.
Q38
- Question: Which of the following code segments is equivalent to the code segment above?
- My Answer:IF(num < 0)
{
DISPLAY(“negative”)
}
ELSE
{
DISPLAY(“positive”)
}
IF(num = 0)
{
DISPLAY(“zero”)
}
- Correct Answer: IF(num < 0)
{
DISPLAY(“negative”)
}
ELSE
{
IF(num = 0)
{
DISPLAY(“zero”)
}
ELSE
{
DISPLAY(“positive”)
}
}
- Reflection: Incorrect. The given code segment displays “positive” when num is positive, displays “negative” when num is negative, and displays “zero” when num is 0. This code segment does not produce the same result for all values of num. For example, “positive zero” is displayed when num is 0.
Q40
- Question: if any, should be made to the code segment to move the robot back to its original position in the bottom-left square of the grid and facing toward the bottom of the grid?
- My Answer: Replace ROTATE_LEFT with ROTATE_RIGHT.
- Correct Answer: No change is needed; the algorithm is correct as is.
- Reflection: Incorrect. After moving forward two squares, turning right, and moving forward four squares, if the robot were to turn right, then the next move forward would put the robot into the black region of the grid.
Q45
- Question: Which of the following are benefits of procedural abstraction?
- My Answer: Procedural abstraction prevents programmers from accidentally using the intellectual property of other programmers.
- Correct Answer: Procedural abstraction provides an opportunity to give a name to a block of code that describes the purpose of the code block.
- Reflection: Incorrect. Procedural abstraction does not prevent programmers from reusing code written by other programmers.
Q49
- Question: A city planner is using simulation software to study crowd flow out of a large arena after an event has ended. The arena is located in an urban city. Which of the following best describes a limitation of using a simulation for this purpose?
- My Answer: Running a simulation requires more time to generate data from trials than observing the crowd exiting the arena at various events.
- Correct Answer: The model used by the simulation software often omits details so that it is easier to implement.
- Reflection: Incorrect. A simulation is often used when a real-world scenario is too impractical to test. A benefit of using a simulation is that it allows for rapid testing.
Q50
- Question: Based on the values in the table, which of the algorithms appear to run in reasonable time?
- My Answer: Algorithm B
- Correct Answer: Algorithm A
- Reflection: Incorrect. As the size of the list grows, the number of steps needed to sort the list grows at an exponential rate, as the number of steps is equal to 2n
for a list of size n
. This indicates that the algorithm does not run in a reasonable amount of time.