Struggling on unit 3 details

Q5 Benefits of Upgraded System

5.1

Answer is D, Incorrect. The upgraded system selects the appropriate department based on the customer’s issue, so the customer does not have the ability to make an incorrect selection.

Q21 Detecting errors in code to sum values in a list

1.4

Answer is A, This option is incorrect. The program does not work as intended. On the test case [9, 1, 4, 5], the program displays 28 but the correct sum is 19.

Q31 Algorithm to open gate in parking garage

3.6

Answer is C, Incorrect. This algorithm will turn on the motor in some cases when the gate sensor is not activated.

Q33 Loop header to move robot to gray square

3.8

Answer is A, Incorrect. This code segment leaves the robot one row above its starting position and one row below the gray square.

Q36 Nested conditionals to set grade

3.7

Answer is B, Incorrect. Code segment I does not work correctly because it is not possible for "C" to be the value of grade at the end of the code segment. Code segment III also works correctly. Code segment III assigns "C" when the numeric score is less than 80, or "B" if the numeric score is not less than 80 but is less than or equal to 90, or "A" otherwise.

Q38 If statement code that produces the same result

3.9

Answer is A, 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 Move robot back to starting place

3.9

Answer is A, Incorrect. After moving forward two squares, if the robot were to turn left, then the next move forward would put the robot beyond the edge of the grid.

Q41 Using binary search on list of genetic codes

3.11

Answer is A, Incorrect. The values can be stored in any numerical base as long as they are sorted.

Q42 Why binary search will not work

3.11

Answer is B, Incorrect. A binary search will work on any sorted list, regardless of whether the list contains duplicate elements.

Q49 Crowd flow simulation

3.16

Answer is A, Incorrect. The model used by a simulation can be modified, both before and after running the simulation. In fact, one of the benefits of using a simulation is the ease of modification.

Q50 Which algorithms run in reasonable time

3.17

Answer is B, 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.