MCQ 5 Blog and Corrections
MCQ 5 Blog and Corrections
MCQ
Results
I scored a 63/66, or 95%
Proof of Completion
Corrections
Q11
My answer: (B)
Correct answer: (D)
The code segment I selected simulates a spinner in which selecting each of three sections is equally likely.
The code segment of (D) selects “Yellow” one-sixth of the time, “Blue” one-sixth of the time, and “Red” the remaining two-thirds of the time.
Q41
My answer: (A) adjustedTotal <– Max(midtermExam, finalExam)
Correct answer: (B) adjustedTotal <– Max(midtermExam, finalExam) + finalExam
My answer was incorrect because the expression assigns only one score to adjustedTotal.
Option (B) is correct because the expression uses the Max procedure to replace the midterm score with the higher of the two scores. The selected value is then added to the final exam score and assigned to adjustedTotal.
Q52
My answer: (C) I and III
Correct answer: (D) II and III
My answer was incorrect because option III works correctly, but option I does not. Option I does not work because it performs the “shorten” step before the “keep palindromes” step.
(D) is the correct answer because options II and III perform the steps in a correct order. In order to generate the desired list, the algorithm must perform the “shorten” step after the “keep palindromes” step, otherwise the “keep palindromes” step would not be able to determine whether the original word was a palindrome.