Score

Corrections

Question 31: This option is incorrect. If a is 30 and b is 50, the original code segment would result in final values of a equals 30 and b equals 70. However, changing line 7 to b, leftward arrow 20. would result in final values of a equals 30 and b equals 20.

Question 32: This option is incorrect. In program II, the value of i starts at n and finishes at 1, so that result stores the sum of n + (n - 1) + … + 3 + 2 + 1. This is the same as 1 + 2 + 3 + … + n.

Question 35: This option is incorrect. If the target value was the first element in a list of many elements, the linear search would require fewer comparisons.

Question 37: This option is incorrect. While the first five commands of this program match the top, bottom, and middle parts of the figure, the right-most part of the figure does not match the last line of the program: Draw (1, left).

Question 38: This option is incorrect. If the initial value of number is 3, the REPEAT UNTIL loop will reduce the value of number to 1, and then to –1, at which point the loop will terminate. The procedure would return false for a value of number greater than 2, which contradicts this statement.

Question 40: This option is incorrect. The robot turns right one, two, or three times and could end up in a square to the left of its initial position. It cannot end up in a square above its initial position.

Question 41: This option is incorrect. The statement Random (1 comma 5) could evaluate to 1, 2, 3, 4, or 5. There is a two out of five, or 40 percent, chance that it could evaluate to 1 or 2. If this happens, the value of sum is increased by 1, which simulates a person voting for the candidate. This does not match the goal of the program, which is to simulate an election in which a certain candidate is expected to receive 20 percent of the vote.

Question 48: This option is incorrect. Because line 1 and line 2 are not inside the FOR EACH loop, interchanging line 1 and line 2 will have no effect on the number of operations performed.